Exemple #1
0
        /// <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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 public void AddDish(Dish dish)
 {
     DishRepository dishRepository = new DishRepository();
     dishRepository.Add(dish);
 }
 public void Post([FromBody] Dish dish)
 {
     DishRepository.Add(dish);
 }
Exemple #6
0
        public void AddDish(Dish dish)
        {
            DishRepository dishRepository = new DishRepository();

            dishRepository.Add(dish);
        }