Esempio n. 1
0
        public IActionResult Create(HomeCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var student = new Cake()
                {
                    nameCake  = model.nameCake,
                    ThanhPhan = model.ThanhPhan,

                    Hsd        = model.Hsd,
                    Nsx        = model.Nsx,
                    GiaBan     = model.GiaBan,
                    DaXoa      = model.DaXoa,
                    CategoryId = model.CategoryId
                };

                var newStd = studentRepository.Create(student);
                if (newStd != null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            //ViewBag.Classes = GetClasses();
            return(View());
        }
        public async Task <ActionResult <Cake> > Create(Cake cake)
        {
            await _cakeRepo.Create(cake);

            if (await _unitOfWork.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Failed to create cake"));
        }
Esempio n. 3
0
        public Cake Create(CakeViewModel cake)
        {
            Cake realCake = new Cake()
            {
                Name        = cake.Name,
                Price       = cake.Price,
                Servings    = cake.Servings,
                GlutenFree  = cake.GlutenFree,
                LactoseFree = cake.LactoseFree,
                NutsFree    = cake.NutsFree
            };

            return(_cakeRepository.Create(realCake));
        }
Esempio n. 4
0
 public IActionResult CreateCake(CakeViewModel model)
 {
     if (ModelState.IsValid)
     {
         var cake = cakeRepository.Create(new Cake()
         {
             CategoryId        = model.CategoryId,
             ExpiryDate        = model.ExpiryDate,
             Ingredient        = model.Ingredient,
             ManufacturingDate = model.ManufacturingDate,
             Name      = model.Name,
             IsDeleted = false,
             Price     = model.Price
         });
         return(RedirectToAction("ViewCake", "Home", new { id = cake.CakeId }));
     }
     ModelState.AddModelError("", "Có lỗi trong quá trình thực hiện, xin hãy thử lại!");
     return(View());
 }