public async Task <IHttpActionResult> PostAsync([FromBody] Food food) { var duplicate = await _foodRepository.FindByDescriptionAsync(food.Description); if (duplicate != null) { return(Conflict()); } _foodRepository.Create(food); try { await _foodRepository.SaveChangedAsync(); } catch (RepositoryException) { return(BadRequest()); } var newFood = await _foodRepository.FindByDescriptionAsync(food.Description); var newFoodLocation = Url.Link("Food", new { foodId = newFood.Id }); return(Created(newFoodLocation, food)); }
public IActionResult Post([FromBody] Food food) { if (food == null) { return(BadRequest()); } _repo.Create(food); return(Ok()); }
public async Task <long> CreateFood(Food food) { food = _foodRepository.Create(food); await _unit.Commit(); await _feedEventService.GenerateFeedEvent(food); await _unit.Commit(); return(food.Id); }
public async Task <FoodItem> Create(FoodItem food) { return(await _repository.Create(food)); }
public IActionResult Create([FromBody] Food entity) { _repository.Create(entity); return(Ok()); }
public void Create(Food entity) { _repository.Create(entity.ToGlobal()); }
public Food Create(Food item) { Repo.Create(item); Unit.SaveChanges(); return(item); }