public Response Update(CreateMealViewModel model) { if (model == null) { return(ResponseFactory.ErrorReponse); } var deleteOldPictureResponse = AzureHelper.DeleteFromBlob(model.Id); if (ResponseFactory.IsSuccessful(deleteOldPictureResponse)) { var file = Request.Files["PictureUrl"]; var url = AzureHelper.Upload(file, "PictureUrl", model.Id); model.PictureUrl = url; } return(MealCore.UpdateMeal(model)); }
public Response Create(CreateMealViewModel model) { if (model == null) { return(ResponseFactory.ErrorReponse); } model.Id = Guid.NewGuid(); var file = Request.Files["PictureUrl"]; var url = AzureHelper.Upload(file, "PictureUrl", model.Id); model.PictureUrl = url; var creationResponse = MealCore.CreateMeal(model); if (!ResponseFactory.IsSuccessful(creationResponse)) { var azureResponse = AzureHelper.DeleteFromBlob(model.Id); } return(creationResponse); }