Exemple #1
0
        public ActionResult Create(LaneInputModel model)
        {
            if (ModelState.IsValid)
            {
                var toSave = Mapper.Map<Lane>(model);
                try
                {
                    this.repos.SaveOrUpdate(toSave);
                    this.repos.DbContext.CommitChanges();
                }
                catch (Exception ex)
                {
                    Error("Something went horribly wrong while saving your changes<br/>Technical stuff: " + ex.Message);
                    return View(model);
                }

                Success("Your new lane was saved");
                return RedirectToAction("Index");
            }

            Error("Darn, your input was incorrect. Please try again");
            return View(model);
        }
Exemple #2
0
        public ActionResult Edit(LaneInputModel model, int id)
        {
            if (ModelState.IsValid)
            {
                var timeslot = Mapper.Map<Lane>(model);
                this.repos.SaveOrUpdate(timeslot);
                this.repos.DbContext.CommitChanges();

                Success("Timeslot was successfully updated");
                return RedirectToAction("Index");
            }
            return View("Create", model);
        }