Beispiel #1
0
        public async Task <IActionResult> PutDish([FromBody] Dish dish)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                DishBLL BLL = new DishBLL(_context);

                return(Ok(await BLL.UpdateDish(dish)));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DishExists(dish.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #2
0
 static DependencyResolver()
 {
     AccountDal = new AccountDAL();
     AccountBLL = new AccountBLL(AccountDal);
     ProductDAL = new ProductDAL();
     ProductBLL = new ProductBLL(ProductDAL);
     DishDAL    = new DishDAL();
     DishBLL    = new DishBLL(DishDAL);
 }
Beispiel #3
0
        public async Task <IActionResult> DeleteDish([FromRoute] int id)
        {
            try
            {
                DishBLL BLL = new DishBLL(_context);

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                return(Ok(await BLL.DeleteDish(id)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #4
0
        public async Task <IActionResult> PostDish([FromBody] Dish dish)
        {
            try
            {
                DishBLL BLL = new DishBLL(_context);

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                await BLL.InsertDish(dish);

                return(CreatedAtAction("GetDish", new { id = dish.Id }, dish));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }