Example #1
0
        public async Task <ActionResult <DishSupply> > CreateDishSupply(DishSupply dishSupply)
        {
            try
            {
                await _unitOfWork.DishSuppliesRepository.InsertTask(dishSupply);

                await _unitOfWork.Commit();

                return(dishSupply);
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
Example #2
0
        public async Task <ActionResult <DishSupply> > UpdateDishSupply(DishSupply dishSupply)
        {
            try
            {
                var dish = await _unitOfWork.DishSuppliesRepository.GetByIdTask(dishSupply.Id);

                if (dish == null)
                {
                    return(NotFound());
                }
                _unitOfWork.DishSuppliesRepository.Update(dish);
                await _unitOfWork.Commit();

                return(dish);
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }