Example #1
0
        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));
        }
Example #2
0
        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);
        }