Пример #1
0
        // GET: RinkOrders/Delete/5
        public ActionResult Delete(int?id, bool?concurrencyError)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RinkOrder rinkOrder = db.RinkOrders.Find(id);

            if (rinkOrder == null)
            {
                if (concurrencyError.GetValueOrDefault())
                {
                    return(RedirectToAction("Index"));
                }
                return(HttpNotFound());
            }

            if (concurrencyError.GetValueOrDefault())
            {
                ViewBag.Error = "The record you attempted to delete "
                                + "was modified by another user after you got the original values. "
                                + "The delete operation was canceled and the current values in the "
                                + "database have been displayed. If you still want to delete this "
                                + "record, click the Delete button again. Otherwise "
                                + "click the Back to List hyperlink.";
            }

            return(View(rinkOrder));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "id,Green,Direction,Boundary,rowversion")] RinkOrder rinkOrder)
        {
            if (ModelState.IsValid)
            {
                db.RinkOrders.Add(rinkOrder);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rinkOrder));
        }
Пример #3
0
        // GET: RinkOrders/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RinkOrder rinkOrder = db.RinkOrders.Find(id);

            if (rinkOrder == null)
            {
                return(HttpNotFound());
            }
            return(View(rinkOrder));
        }
Пример #4
0
        // GET: RinkOrders/Create
        public ActionResult Create()
        {
            var list = db.RinkOrders.OrderBy(x => x.id).ToList();
            int id   = 1;

            if (list.Any())
            {
                id = list.Last().id + 1;
            }
            var item = new RinkOrder()
            {
                id = id
            };

            return(View(item));
        }
Пример #5
0
        public ActionResult Edit([Bind(Include = "id,Green,Direction,Boundary,rowversion")] RinkOrder rinkOrder)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(rinkOrder).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var entry         = ex.Entries.Single();
                var clientValues  = (RinkOrder)entry.Entity;
                var databaseEntry = entry.GetDatabaseValues();
                if (databaseEntry == null)
                {
                    ModelState.AddModelError(string.Empty,
                                             "Unable to save changes. The rink was deleted by another user.");
                }
                else
                {
                    var databaseValues = (RinkOrder)databaseEntry.ToObject();

                    if (databaseValues.id != clientValues.id)
                    {
                        ModelState.AddModelError("id", "Current value: "
                                                 + databaseValues.id);
                    }
                    if (databaseValues.Direction != clientValues.Direction)
                    {
                        ModelState.AddModelError("Direction", "Current value: "
                                                 + databaseValues.Direction);
                    }
                    if (databaseValues.Green != clientValues.Green)
                    {
                        ModelState.AddModelError("Green", "Current value: "
                                                 + databaseValues.Green);
                    }
                    if (databaseValues.Boundary != clientValues.Boundary)
                    {
                        ModelState.AddModelError("Boundary", "Current value: "
                                                 + databaseValues.Boundary);
                    }
                    ModelState.AddModelError(string.Empty, "The record you attempted to edit "
                                             + "was modified by another user after you got the original value. The "
                                             + "edit operation was canceled and the current values in the database "
                                             + "have been displayed. If you still want to edit this record, click "
                                             + "the Save button again. Otherwise click the Back to List hyperlink.");
                    rinkOrder.rowversion = databaseValues.rowversion;
                }
            }
            catch (Exception dex)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                ErrorSignal.FromCurrentContext().Raise(dex);
            }
            return(View(rinkOrder));
        }