public BaseResponse <int> Update([FromBody] Food food) { BaseResponse <int> response = null; try { string token = Request.Headers["Auth"]; User user = businessLogicLayer.Check(token); if (food.Author.Id != user.Id) { throw new MethodAccessException("Updating other people's recipes is not available"); } using (WebClient webClient = new WebClient()) { byte[] image = webClient.DownloadData(food.Image); food.Image = Convert.ToBase64String(image); } businessLogicLayer.UpdateFoodWithProducts(food); response = new BaseResponse <int>(0); } catch (Exception ex) { response = new BaseResponse <int> { Error = ex.Message }; } return(response); }