Exemplo n.º 1
0
        public ActionResult Edit(int guid)
        {
            MarkSizeType         model      = CarraraSQL.MarkSizeTypes.Find(guid);
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model == null)
            {
                TempData["Page.Title"] = "Unable to Locate Mark Size Type with Id " + guid.ToString() + "!";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title = TempData["Page.Title"] != null ? TempData["Page.Title"].ToString() : "Edit " + model.MarkSizeTypeName;
            return(View("Manage", model));
        }
Exemplo n.º 2
0
        public ActionResult Add(MarkSizeType model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (ModelState.IsValid)
            {
                CarraraSQL.MarkSizeTypes.Add(model);
                CarraraSQL.SaveChanges();
                HttpContext.Cache.Remove("MarkSizeTypesSelectList");
                TempData["Page.Title"] = "The Mark Size Type Was Added Successfully!";
                return(RedirectToAction("Index", parameters));
            }
            // Failure is always an option...
            Page.Title   = "The Mark Size Type Was NOT Added!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }
Exemplo n.º 3
0
        public ActionResult Edit(MarkSizeType model)
        {
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model.Action == "Delete")
            {
                MarkSizeType entity = CarraraSQL.MarkSizeTypes.Find(model.MarkSizeTypeID);
                if (entity.MarkTypes.Any())
                {
                    Page.Title   = "The Mark Size Type Is In Use And Was NOT Deleted!";
                    Page.Message = "Set the Mark Size Type to Inactive if you do not intend to use this Mark Size Type again.";
                    return(View("Manage", model));
                }
                try
                {
                    CarraraSQL.MarkSizeTypes.Attach(model);
                    CarraraSQL.MarkSizeTypes.Remove(model);
                    CarraraSQL.SaveChanges();
                    HttpContext.Cache.Remove("MarkSizeTypesSelectList");
                    TempData["Page.Title"] = "The Mark Size Type Was Deleted Successfully";
                    return(RedirectToAction("Index", parameters));
                }
                catch (Exception ex)
                {
                    Page.Title = "The Mark Size Type Was NOT Deleted! " + ex.Message;
                    return(View("Manage", model));
                }
            }
            if (ModelState.IsValid)
            {
                CarraraSQL.Entry(model).State = EntityState.Modified;
                CarraraSQL.SaveChanges();
                HttpContext.Cache.Remove("MarkSizeTypesSelectList");
                TempData["Page.Title"] = "The Mark Size Type Was Updated Successfully";
                return(RedirectToAction("Index", parameters));
            }
            Page.Title   = "The Mark Size Type Was NOT Updated!";
            Page.Message = "Please correct the following errors:";
            return(View("Manage", model));
        }