public ActionResult EditPost(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Repairer repairerToUpdate = db.Repairers.Find(id);

            repairerToUpdate.Wage = DoubleExtension.ConvertInput(Request.Form["WageTextbox"]);

            if (TryUpdateModel(repairerToUpdate, "", new string[] { "RepairerId", "FirstName", "LastName", "DoB", "Wage" }))
            {
                try
                {
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                catch (DataException Dex)
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                    return(View("Error", new HandleErrorInfo(Dex, "Repairer", "EditPost")));
                }
            }
            return(View(repairerToUpdate));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ProductId,Name,Price")] Product product)
        {
            if (ModelState.IsValid)
            {
                Assignment assignment = db.Assignments.Find(Request.Form["AssignmentId"]);
                product.Assignment = assignment;
                product.Price      = DoubleExtension.ConvertInput(Request.Form["PriceTextbox"]);
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }