Exemplo n.º 1
0
 public ActionResult Edit(string id, Category category)
 {
     try
     {
         using (DaVentiDBEntities en = new DaVentiDBEntities())
         {
             en.Entry(category).State = EntityState.Modified;
             en.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 2
0
        public ActionResult Create(Category category)
        {
            try
            {
                using (DaVentiDBEntities en = new DaVentiDBEntities())
                {
                    en.Categories.Add(category);
                    en.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 3
0
 public ActionResult Edit(string id, Promo promo)
 {
     try
     {
         // TODO: Add update logic here
         using (DaVentiDBEntities dBEntities = new DaVentiDBEntities())
         {
             dBEntities.Entry(promo).State = EntityState.Modified;
             dBEntities.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 4
0
 public ActionResult Create(Promo promo)
 {
     try
     {
         // TODO: Add insert logic here
         using (DaVentiDBEntities dBEntities = new DaVentiDBEntities())
         {
             dBEntities.Promoes.Add(promo);
             dBEntities.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Delete(string id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         using (DaVentiDBEntities dBEntities = new DaVentiDBEntities())
         {
             Book book = dBEntities.Books.Where(x => x.id_book == id).FirstOrDefault();
             dBEntities.Books.Remove(book);
             dBEntities.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(Book book)
 {
     try
     {
         using (DaVentiDBEntities dBEntities = new DaVentiDBEntities())
         {
             dBEntities.Books.Add(book);
             dBEntities.SaveChanges();
         }
         // TODO: Add insert logic here
         ViewBag.Message = "Book added";
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 7
0
        public ActionResult Delete(string id, FormCollection collection)
        {
            try
            {
                using (DaVentiDBEntities en = new DaVentiDBEntities())
                {
                    Category category = en.Categories.Where(x => x.id_category == id).FirstOrDefault();
                    en.Categories.Remove(category);
                    en.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Registration(Employee employee)
        {
            bool   Status  = false;
            string message = "";

            // model validation
            if (ModelState.IsValid)
            {
                #region email already exist
                var isExist = IsEmailExist(employee.email_emp);

                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already exist");
                    return(View(employee));
                }
                #endregion


                #region saving to database
                using (DaVentiDBEntities en = new DaVentiDBEntities())
                {
                    en.Employees.Add(employee);
                    en.SaveChanges();

                    message = "Registration successful. Welcome abroad!";
                    Status  = true;
                }
                #endregion
            }
            else
            {
                message = "Invalid request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(employee));
        }