Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 4
0
 public void AddDish(Dish dish)
 {
     DishRepository dishRepository = new DishRepository();
     dishRepository.Add(dish);
 }
Ejemplo n.º 5
0
 public void Post([FromBody] Dish dish)
 {
     DishRepository.Add(dish);
 }
Ejemplo n.º 6
0
        public void AddDish(Dish dish)
        {
            DishRepository dishRepository = new DishRepository();

            dishRepository.Add(dish);
        }