Пример #1
0
        public ActionResult Create(OurChefs model)
        {
            if (ModelState.IsValid)
            {
                var dao = new OurChefDao();

                long id = dao.Insert(model);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "OurChef"));
                }
                else
                {
                    ModelState.AddModelError("", "Them OurChef thanh cong");
                }
            }
            return(View("Index"));
        }
Пример #2
0
        public ActionResult Edit(OurChefs model)
        {
            if (ModelState.IsValid)
            {
                var dao = new OurChefDao();

                if (!string.IsNullOrEmpty(model.Name))
                {
                    var result = dao.Update(model);
                    if (result)
                    {
                        return(RedirectToAction("Index", "OurChef"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Cap nhap thanh cong");
                    }
                }
            }
            return(View());
        }
Пример #3
0
 public bool Update(OurChefs entity)
 {
     try
     {
         var ourChef = db.OurChefs.Find(entity.ID);
         ourChef.Name         = entity.Name;
         ourChef.CreateDate   = DateTime.Now;
         ourChef.Address      = entity.Address;
         ourChef.Descripton   = entity.Descripton;
         ourChef.Email        = entity.Email;
         ourChef.Image        = entity.Image;
         ourChef.LinkFb       = entity.LinkFb;
         ourChef.LinkInstagam = entity.LinkInstagam;
         ourChef.office       = entity.office;
         ourChef.Phone        = entity.Phone;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #4
0
 public long Insert(OurChefs entity)
 {
     db.OurChefs.Add(entity);
     db.SaveChanges();
     return(entity.ID);
 }