示例#1
0
        public ActionResult AddAnticorrosive(Anticorrosive anticorrosive)
        {
            if (!User.IsInRole("admin"))
            {
                return(View("Error"));
            }

            using (OvpNgContext db = new OvpNgContext())
            {
                DateTime dateTimeNow = DateTime.Now;
                anticorrosive.CreatedAt  = dateTimeNow;
                anticorrosive.LastEditAt = dateTimeNow;
                anticorrosive.LastEditBy = User.Identity.Name;
                anticorrosive.CreatedBy  = User.Identity.Name;

                db.Anticorrosives.Add(anticorrosive);
                db.SaveChanges();
            }

            return(RedirectToAction("Anticorrosive"));
        }
示例#2
0
        public ActionResult DeleteAnticorrosive(Anticorrosive anticorrosive)
        {
            if (!User.IsInRole("admin"))
            {
                return(View("Error"));
            }

            using (OvpNgContext db = new OvpNgContext())
            {
                Anticorrosive deletingAnticorrosive = new Anticorrosive
                {
                    Id = anticorrosive.Id
                };

                db.Anticorrosives.Attach(deletingAnticorrosive);
                db.Anticorrosives.Remove(deletingAnticorrosive);

                db.SaveChanges();
            }
            return(RedirectToAction("Anticorrosive"));
        }