/// <summary> /// /// Create /// /// Right = Admin, Instructor /// /// Exception = validation /// /// </summary> public bool Add(int userId, IDish dish) { if (!UserLogic.CheckRight(userId, Right.Admin) || UserLogic.CheckRight(userId, Right.Instructor)) { return(false); } return(_repository.Add(dish)); }
public ActionResult Add(DishInfo model) { Employee em = (Employee)Session[CommonConstants.USER_SESSION]; model.CreatedBy = em.id; model.ModifyBy = em.id; model.DishCode = model.DishCode.ToUpper(); //Chuyển trường mã thành dạng chữ in hoa var result = _dishRepo.Add(model); if (result == 1) { return(Json(new { status = 1, message = "Thêm thành công" }, JsonRequestBehavior.AllowGet)); } return(Json(new { status = 0, message = "Thêm thất bại" }, JsonRequestBehavior.AllowGet)); }
public async Task <IHttpActionResult> Post([FromBody] Dish dish) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (await DishRepository.ExistsAsync(elem => elem.Name == dish.Name)) { return(BadRequest("The dish name already exists.Please type another one.")); } dish.Id = await DishRepository.GenerateIdAsync(); DishRepository.Add(dish); await UnitOfWork.CommitAsync(); return(CreatedAtRoute("GetDishById", new { id = dish.Id }, dish)); }
public void AddDish(Dish dish) { DishRepository dishRepository = new DishRepository(); dishRepository.Add(dish); }
public void Post([FromBody] Dish dish) { DishRepository.Add(dish); }