예제 #1
0
        public ActionResult Create(TimeSlotInputModel model)
        {
            if (ModelState.IsValid)
            {
                var toSave = Mapper.Map<TimeSlot>(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 time slot was saved");
                return RedirectToAction("Index");
            }

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

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