Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "Id,Name,Unit,Hours")] Rule2_Master rule2_Master)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                System.Collections.Generic.List <Rule2_Master> getName = db.Rule2_Master.Where(u => u.Name == rule2_Master.Name && u.Id != rule2_Master.Id).ToList();

                if (getName.Count > 0)
                {
                    ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist");
                    return(View());
                }
                else
                {
                    db.Entry(rule2_Master).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["message"] = ToasterMessage.Message(ToastType.success, "Updated Successfully");
                    return(RedirectToAction("Index"));
                }
                //}
            }
            catch (DbEntityValidationException e)
            {
                string errorMessage = string.Empty;

                foreach (DbEntityValidationResult eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);

                    foreach (DbValidationError ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                        errorMessage = ve.ErrorMessage;

                        ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage);
                    }
                }
                return(View());
            }
            catch (Exception)
            {
                ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong");
            }

            return(View());
        }
Ejemplo n.º 2
0
        // GET: Rule2_Master/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Rule2_Master rule2_Master = db.Rule2_Master.Find(id);

            if (rule2_Master == null)
            {
                return(HttpNotFound());
            }

            return(View(rule2_Master));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                Rule2_Master rule2_Master = db.Rule2_Master.Find(id);
                db.Rule2_Master.Remove(rule2_Master);
                db.SaveChanges();

                TempData["message"] = ToasterMessage.Message(ToastType.success, "Deleted successfully");
                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException e)
            {
                string errorMessage = string.Empty;

                foreach (DbEntityValidationResult eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);

                    foreach (DbValidationError ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                        errorMessage = ve.ErrorMessage;

                        ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage);
                    }
                }
                return(View());
            }
            catch (Exception)
            {
                ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong");
            }
            return(View());
        }