added notes in recipe

This commit is contained in:
Samuele Locatelli
2020-07-17 13:53:45 +02:00
parent e7cb0028d0
commit c5670eca9d
2 changed files with 24 additions and 2 deletions
@@ -31,6 +31,10 @@ namespace Thermo.Active.Model.DTOModels.ThRecipe
/// Last TC observed (stats) in sec
/// </summary>
public double TC_last = 3600;
/// <summary>
/// Note ricetta
/// </summary>
public string recipeNotes = "";
}
@@ -474,10 +474,23 @@ namespace Thermo.Active.Controllers.WebApi
return Ok();
}
[Route("updateNote"), HttpPost]
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
public IHttpActionResult UpdateNote(string recipeNotes)
{
// salvo note...
if (!string.IsNullOrEmpty(recipeNotes))
{
NcFileAdapter.RecipeLiveData.recipeNotes = recipeNotes.Trim();
}
// e salvo su disco
NcFileAdapter.SaveRecipe(NcFileAdapter.RecipeLiveData.RecipeName, NcFileAdapter.RecipeLiveData);
return Ok();
}
[Route("saveAll"), HttpPost]
[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)]
public async Task<IHttpActionResult> SaveAll(string newName, double estimTimeSec)
public async Task<IHttpActionResult> SaveAll(string newName, string recipeNotes, double estimTimeSec)
{
// recupero dati utente loggato
var identity = User.Identity as ClaimsIdentity;
@@ -492,6 +505,12 @@ namespace Thermo.Active.Controllers.WebApi
NcFileAdapter.RecipeLiveData.UserSave = userData.Id.ToString();
}
// salvo note...
if(!string.IsNullOrEmpty(recipeNotes))
{
NcFileAdapter.RecipeLiveData.recipeNotes = recipeNotes.Trim();
}
bool imageUploaded = false;
if (!Request.Content.IsMimeMultipartContent())
@@ -538,7 +557,6 @@ namespace Thermo.Active.Controllers.WebApi
// e salvo su disco
NcFileAdapter.SaveRecipe(newName, NcFileAdapter.RecipeLiveData);
}
return Ok();
}