Exemple #1
0
        public ActionResult EditSeries(SeriesEdit model, HttpPostedFileBase pictureUpload = null)
        {
            ActionResult RenderEdit()
            {
                model.AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(PermissionContext).ToArray();
                return(View("EditSeries", model));
            }

            // Note: name is allowed to be whitespace, but not empty.
            if (model.Names == null || model.Names.All(n => string.IsNullOrEmpty(n?.Value)))
            {
                ModelState.AddModelError("Names", "Name cannot be empty");
            }

            if (!ModelState.IsValid)
            {
                return(RenderEdit());
            }

            var pictureData = ParsePicture(pictureUpload, "Picture", ImagePurpose.Main);

            int id;

            try {
                id = queries.UpdateSeries(model.ToContract(), pictureData);
            } catch (DuplicateEventNameException x) {
                ModelState.AddModelError("Names", x.Message);
                return(RenderEdit());
            }

            return(RedirectToAction("SeriesDetails", new { id }));
        }
        public ActionResult Edit(int id, SeriesEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.SeriesId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateSeriesService();

            if (service.UpdateSeries(model))
            {
                TempData["SaveResult"] = "The series was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "The series could not be updated.");

            return(View(model));
        }
Exemple #3
0
        public ActionResult EditSeries(SeriesEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Service.UpdateSeries(model.ToContract());

            return(RedirectToAction("EventsBySeries"));
        }
Exemple #4
0
        public ActionResult EditSeries(SeriesEdit model, HttpPostedFileBase pictureUpload = null)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var pictureData = ParsePicture(pictureUpload, "Picture");

            var id = queries.UpdateSeries(model.ToContract(), pictureData);

            return(RedirectToAction("SeriesDetails", new { id }));
        }
        public ActionResult Edit(int id)
        {
            var service = CreateSeriesService();
            var detail  = service.GetSeriesById(id);

            var model = new SeriesEdit
            {
                SeriesId          = detail.SeriesId,
                SeriesName        = detail.SeriesName,
                SeriesDescription = detail.SeriesDescription
            };

            return(View(model));
        }
Exemple #6
0
        public bool UpdateSeries(SeriesEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .SeriesPlural
                    .Single(e => e.SeriesId == model.SeriesId);

                entity.SeriesId          = model.SeriesId;
                entity.SeriesName        = model.SeriesName;
                entity.SeriesDescription = model.SeriesDescription;

                return(ctx.SaveChanges() == 1);
            }
        }