public ActionResult Create(string id) { if (!Request.IsAuthenticated) { throw new AuthenticationException(); } AlbumCreateEditViewModel model; if (string.IsNullOrEmpty(id)) { var user = DataService.PerThread.BaseUserSet.OfType <User>().SingleOrDefault(x => x.Id == UserContext.Current.Id); if (user == null) { throw new BusinessLogicException("Перезайдите"); } model = new AlbumCreateEditViewModel(user); } else { var group = GroupService.GetGroupByLabelOrId(id); var gm = GroupService.UserInGroup(UserContext.Current.Id, group, true); if (gm.State != (byte)GroupMemberState.Moderator) { throw new BusinessLogicException("Только модераторы могут создавать альбомы в группах"); } model = new AlbumCreateEditViewModel(group); } return(View(model)); }
public ActionResult Edit(AlbumCreateEditViewModel model) { if (!Request.IsAuthenticated) { throw new AuthenticationException(); } if (!ModelState.IsValid) { return(View(model)); } var album = AlbumService.EditAlbum(UserContext.Current, model.AlbumId, model.Title, model.Description, model.IsOpen); return(RedirectToAction("index", new { id = album.Id })); }
public ActionResult Create(AlbumCreateEditViewModel model) { if (!Request.IsAuthenticated) { throw new AuthenticationException(); } if (!ModelState.IsValid) { return(View(model)); } var album = AlbumService.CreateAlbum(model.GroupId, model.UserId, model.Title, model.Description, model.IsOpen); if (Request.UrlReferrer != null && Request.UrlReferrer.Segments[2] == "albumsforeditor") { return(RedirectToAction("foreditor", "album", new { id = album.Id })); } return(RedirectToAction("index", new { id = album.Id })); }