Exemple #1
0
        public ActionResult Edit(BookingEditModel model)
        {
            if (!this.ModelState.IsValid)
            {
                this.ViewBag.Error = ModelValidationErrors.InvalidModel;
                return(this.View(model));
            }

            var booking = this.bookings.GetById(model.Id);

            if (booking == null)
            {
                this.TempData["Error"] = ModelValidationErrors.EditDeletedEntity;
                return(this.RedirectToAction("Index"));
            }

            booking.BookedFrom = model.BookedFrom;
            booking.BookedTo   = model.BookedTo;
            this.bookings.Update();

            this.TempData["Success"] = "Booking was successful edited!";
            return(this.RedirectToAction("Index"));
        }
        public ActionResult Edit(BookingEditModel model)
        {
            if (!this.ModelState.IsValid)
            {
                this.ViewBag.Error = ModelValidationErrors.InvalidModel;
                return this.View(model);
            }

            var booking = this.bookings.GetById(model.Id);
            if (booking == null)
            {
                this.TempData["Error"] = ModelValidationErrors.EditDeletedEntity;
                return this.RedirectToAction("Index");
            }

            booking.BookedFrom = model.BookedFrom;
            booking.BookedTo = model.BookedTo;
            this.bookings.Update();

            this.TempData["Success"] = "Booking was successful edited!";
            return this.RedirectToAction("Index");
        }