예제 #1
0
        public EventEdit(ReleaseEventSeriesContract seriesContract, IUserPermissionContext userContext)
            : this()
        {
            Series = seriesContract;

            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(userContext).ToArray();
        }
예제 #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 }));
        }
예제 #3
0
        public void CopyNonEditableProperties(TagForEditContract contract, IUserPermissionContext permissionContext)
        {
            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(permissionContext).ToArray();
            CanDelete            = contract.CanDelete;
            CurrentName          = contract.Name;
            Deleted = contract.Deleted;
            Id      = contract.Id;
            IsEmpty = contract.IsEmpty;
            Thumb   = contract.Thumb;
            UrlSlug = contract.UrlSlug;

            string GetTagTargetTypeName(TagTargetTypes t)
            {
                switch (t)
                {
                case TagTargetTypes.Nothing:
                    return("Nothing");

                case TagTargetTypes.All:
                    return("Anything");
                }
                return(string.Join(", ", EnumVal <EntryType> .Values.Where(e => e != EntryType.Undefined).Where(e => t.HasFlag((TagTargetTypes)e)).Select(e => Translate.EntryTypeNames[e])));
            }

            AllTagTargetTypes = new[] { TagTargetTypes.Album, TagTargetTypes.Artist, TagTargetTypes.Song, TagTargetTypes.Event }
            .ToDictionary(t => t, GetTagTargetTypeName);
        }
예제 #4
0
        public void CopyNonEditableProperties(ReleaseEventSeriesForEditContract contract, IUserPermissionContext userContext)
        {
            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(userContext).ToArray();

            if (contract != null)
            {
                Deleted = contract.Deleted;
            }
        }
예제 #5
0
        public void CopyNonEditableFields(ArtistForEditContract artist)
        {
            ParamIs.NotNull(() => artist);

            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(MvcApplication.LoginManager);
            Deleted          = artist.Deleted;
            Draft            = artist.Status == EntryStatus.Draft;
            ValidationResult = artist.ValidationResult;
        }
예제 #6
0
        public void CopyNonEditableFields(SongForEditContract song)
        {
            ParamIs.NotNull(() => song);

            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(MvcApplication.LoginManager);
            Deleted          = song.Deleted;
            Draft            = song.Song.Status == EntryStatus.Draft;
            Name             = song.Song.Name;
            ValidationResult = song.ValidationResult;
        }
예제 #7
0
        public ArtistEditViewModel(ArtistContract artist, IUserPermissionContext permissionContext,
                                   ArtistForEditContract editedArtist = null)
            : this()
        {
            ParamIs.NotNull(() => artist);

            Artist = artist;
            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(permissionContext);
            EditedArtist         = editedArtist;
        }
예제 #8
0
        public SongEditViewModel(SongContract song, IUserPermissionContext permissionContext,
                                 SongForEditContract editedSong = null)
            : this()
        {
            ParamIs.NotNull(() => song);

            Song = song;
            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(permissionContext);
            EditedSong           = editedSong;
        }
예제 #9
0
        public AlbumEditViewModel(AlbumContract album, IUserPermissionContext permissionContext,
                                  AlbumForEditContract editedAlbum = null)
            : this()
        {
            ParamIs.NotNull(() => album);

            Album       = album;
            EditedAlbum = editedAlbum;

            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(permissionContext);
        }
예제 #10
0
 public void CopyNonEditableProperties(TagForEditContract contract, IUserPermissionContext permissionContext)
 {
     AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(permissionContext).ToArray();
     CanDelete            = contract.CanDelete;
     CurrentName          = contract.Name;
     Deleted = contract.Deleted;
     Id      = contract.Id;
     IsEmpty = contract.IsEmpty;
     Thumb   = contract.Thumb;
     UrlSlug = contract.UrlSlug;
 }
예제 #11
0
        public void CopyNonEditableProperties(ReleaseEventDetailsContract contract, IUserPermissionContext userContext)
        {
            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(userContext).ToArray();

            if (contract != null)
            {
                Deleted     = contract.Deleted;
                OldName     = contract.Name;
                PictureMime = contract.PictureMime;
                UrlSlug     = contract.UrlSlug;
                Version     = contract.Version;
            }
        }
예제 #12
0
        public void CopyNonEditableFields(AlbumForEditContract album)
        {
            ParamIs.NotNull(() => album);

            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(MvcApplication.LoginManager);
            ArtistLinks          = album.ArtistLinks;
            Deleted          = album.Deleted;
            Draft            = album.Status == EntryStatus.Draft;
            NameEnglish      = album.TranslatedName.English;
            NameJapanese     = album.TranslatedName.Japanese;
            NameRomaji       = album.TranslatedName.Romaji;
            ValidationResult = album.ValidationResult;
        }
예제 #13
0
        public SongEditViewModel(SongContract song, IUserPermissionContext permissionContext,
                                 bool canDelete,
                                 SongForEditContract editedSong = null, int?albumId = null)
            : this()
        {
            ParamIs.NotNull(() => song);

            Song = song;
            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(permissionContext).ToArray();
            CanDelete            = canDelete;
            EditedSong           = editedSong;
            AlbumId = albumId;
        }
예제 #14
0
        public VenueEditViewModel(VenueForEditContract contract, IUserPermissionContext permissionContext)
        {
            ParamIs.NotNull(() => contract);

            Address             = contract.Address;
            AddressCountryCode  = contract.AddressCountryCode;
            Coordinates         = contract.Coordinates;
            DefaultNameLanguage = contract.DefaultNameLanguage;
            Deleted             = contract.Deleted;
            Description         = contract.Description;
            Id       = contract.Id;
            Name     = contract.Name;
            Names    = contract.Names;
            Status   = contract.Status;
            WebLinks = contract.WebLinks;

            AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(permissionContext).ToArray();
        }
예제 #15
0
        public ActionResult Edit(VenueEditViewModel 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 ((model.Coordinates != null) && !OptionalGeoPoint.IsValid(model.Coordinates.Latitude, model.Coordinates.Longitude))
            {
                ModelState.AddModelError("Coordinates", "Invalid coordinates");
            }

            if (!ModelState.IsValid)
            {
                model.AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(PermissionContext).ToArray();
                return(View(model));
            }

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

            return(RedirectToAction("Details", new { id }));
        }
예제 #16
0
 public TagEdit()
 {
     AllowedEntryStatuses = EntryPermissionManager.AllowedEntryStatuses(MvcApplication.LoginManager).Where(e => e != EntryStatus.Draft).ToArray();
 }