Exemple #1
0
        public void UpdateSeries_Create()
        {
            var contract = new ReleaseEventSeriesForEditContract {
                Names = Names("Comiket")
            };

            var result = queries.UpdateSeries(contract, null);

            var seriesFromRepo = repository.Load <ReleaseEventSeries>(result);

            Assert.AreEqual(2, repository.List <ReleaseEventSeries>().Count, "Number of series in repo");
            Assert.IsNotNull(seriesFromRepo, "Series was loaded successfully");
            Assert.AreEqual("Comiket", seriesFromRepo.TranslatedName.Default, "Name was updated");
        }
Exemple #2
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 }));
        }
Exemple #3
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 }));
        }