예제 #1
0
        private ReleaseEventForEditContract Update(ReleaseEventForEditContract contract)
        {
            return(context.RunTest(repository => {
                var queries = new EventQueries(repository, entryLinkFactory, userContext, imageStore, userIconFactory, enumTranslations, mailer);

                var updated = queries.Update(contract, null);

                return queries.GetEventForEdit(updated.Id);
            }));
        }
        private ReleaseEventForEditContract Update(ReleaseEventForEditContract contract)
        {
            return(context.RunTest(repository => {
                var queries = new EventQueries(repository, entryLinkFactory, userContext, imageStore, userIconFactory, enumTranslations, mailer,
                                               new FollowedArtistNotifier(new FakeEntryLinkFactory(), new FakeUserMessageMailer(), new EnumTranslations(), new EntrySubTypeNameFactory()));

                var updated = queries.Update(contract, null);

                return queries.GetEventForEdit(updated.Id);
            }));
        }
예제 #3
0
        public async Task <ActionResult> Edit(EventEdit model, IFormFile pictureUpload = null)
        {
            ActionResult RenderEdit()
            {
                if (model.Id != 0)
                {
                    var contract = _queries.GetEventForEdit(model.Id);
                    model.CopyNonEditableProperties(contract, PermissionContext);
                }
                else
                {
                    model.CopyNonEditableProperties(null, PermissionContext);
                }

                return(View("Edit", model));
            }

            // Either series or name must be specified. If series is specified, name is generated automatically.
            if (model.Series.IsNullOrDefault() || model.CustomName)
            {
                // 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, "pictureUpload", ImagePurpose.Main);

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

            int id;

            try
            {
                id = (await _queries.Update(model.ToContract(), pictureData)).Id;
            }
            catch (DuplicateEventNameException x)
            {
                ModelState.AddModelError("Names", x.Message);
                return(RenderEdit());
            }

            return(RedirectToAction("Details", new { id }));
        }
예제 #4
0
        public ActionResult Edit(EventEdit model)
        {
            // Either series or name must be specified. If series is specified, name is generated automatically.
            if (!model.SeriesId.HasValue && string.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", "Name cannot be empty");
            }

            if (!ModelState.IsValid)
            {
                if (model.Id != 0)
                {
                    var contract = Service.GetReleaseEventForEdit(model.Id);
                    model.CopyNonEditableProperties(contract);
                }

                return(View(model));
            }

            var id = queries.Update(model.ToContract()).Id;

            return(RedirectToAction("Details", new { id }));
        }
예제 #5
0
        public ActionResult Edit(EventEdit model, HttpPostedFileBase pictureUpload = null)
        {
            // Either series or name must be specified. If series is specified, name is generated automatically.
            if (string.IsNullOrEmpty(model.Name) && (model.Series.IsNullOrDefault() || model.CustomName))
            {
                ModelState.AddModelError("Name", "Name cannot be empty");
            }

            if (!ModelState.IsValid)
            {
                if (model.Id != 0)
                {
                    var contract = Service.GetReleaseEventForEdit(model.Id);
                    model.CopyNonEditableProperties(contract);
                }

                return(View(model));
            }

            var pictureData = ParsePicture(pictureUpload, "pictureUpload");
            var id          = queries.Update(model.ToContract(), pictureData).Id;

            return(RedirectToAction("Details", new { id }));
        }
예제 #6
0
        private ReleaseEvent CallUpdate(ReleaseEventForEditContract contract)
        {
            var result = queries.Update(contract, null);

            return(repository.Load(result.Id));
        }
예제 #7
0
        private ReleaseEvent CallUpdate(ReleaseEventDetailsContract contract)
        {
            var result = queries.Update(contract);

            return(repository.Load(result.Id));
        }
예제 #8
0
        private async Task <ReleaseEvent> CallUpdate(ReleaseEventForEditContract contract)
        {
            var result = await queries.Update(contract, null);

            return(repository.Load(result.Id));
        }