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; } } }
static DependencyResolver() { AccountDal = new AccountDAL(); AccountBLL = new AccountBLL(AccountDal); ProductDAL = new ProductDAL(); ProductBLL = new ProductBLL(ProductDAL); DishDAL = new DishDAL(); DishBLL = new DishBLL(DishDAL); }
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)); } }
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)); } }