public async Task <IEnumerable <AlbumDto> > GetSpotifyAlbums(List <string> albumsIdToGet) { var auth = new CredentialsAuth(ClientId, SecretId); var token = await auth.GetToken(); var api = new SpotifyWebAPI() { TokenType = token.TokenType, AccessToken = token.AccessToken }; var albumsFromSpotify = await api.GetSeveralAlbumsAsync(albumsIdToGet); var albumsToReturn = new List <AlbumDto>(); foreach (var album in albumsFromSpotify.Albums) { var albumToReturn = new AlbumDto { Artist = album.Artists[0].Name, ArtistId = album.Artists[0].Id, Name = album.Name, Id = album.Id, UserId = 1, CoverUrl = album.Images[0].Url, Year = album.ReleaseDate.Substring(0, 4) }; albumsToReturn.Add(albumToReturn); } return(albumsToReturn); }
public async Task <IActionResult> AddNew(AlbumDto entityDto) { _dbContext.Connection.Open(); using (var transaction = _dbContext.Connection.BeginTransaction()) { try { _dbContext.Database.UseTransaction(transaction as DbTransaction); bool GenresExists = await _dbContext.Albums.AnyAsync(a => a.Title == entityDto.Title); if (GenresExists) { return(BadRequest(new { msg = "Album Already Exists" })); } var addGenresQuery = $"INSERT INTO albums(Title,ArtistId) VALUES('{entityDto.Title}','{entityDto.ArtistId}');SELECT last_insert_rowid()"; var genresId = await _writeDbConnection.QuerySingleAsync <int>(addGenresQuery, transaction : transaction); if (genresId == 0) { return(BadRequest(new { msg = "Album could not be inserted" })); } await _dbContext.SaveChangesAsync(default);
public bool Update(AlbumDto albumDto) { using (UnitOfWork unitOfWork = new UnitOfWork()) { var result = unitOfWork.AlbumRepository.GetById(albumDto.Id); if (result == null) { return(false); } result.AlbumTitle = albumDto.AlbumTitle; result.AlbumDescription = albumDto.AlbumDescription; result.AlbumReleaseDate = albumDto.AlbumReleaseDate; result.AlbumNumberOfSongs = albumDto.AlbumNumberOfSongs; result.AlbumPrice = albumDto.AlbumPrice; result.AlbumRating = albumDto.AlbumRating; result.ArtistId = albumDto.ArtistId; result.GenreId = albumDto.GenreId; result.SongId = albumDto.SongId; result.UpdatedOn = DateTime.Now; unitOfWork.AlbumRepository.Update(result); return(unitOfWork.Save()); } }
private void LoadRoot() { _treeList.Clear(); // загрузка корневой ноды дерева var root = _ctx.Albums.FirstOrDefault(x => !x.ParentId.HasValue); if (root != null) { var alb = new AlbumDto(root); _treeList.Add(alb); tlwAlbums.Roots = new List <AlbumDto>() { alb }; LoadChildrenTree(alb); // ... и дочерних, для плюсиков в дереве foreach (var ch in alb.ChildIds) { var chAlb = _treeList.Where(x => x.Id == ch).First(); LoadChildrenTree(chAlb); } tlwAlbums.Expand(alb); } }
private void DisplayNode(AlbumDto node, string songSearched) { tlwAlbums.Focus(); var parents = new List <int>(); var n = node; while (n.ParentId.HasValue) { parents.Add(n.ParentId.Value); var alb = _ctx.Albums.Where(x => x.Id == n.ParentId).First(); n = new AlbumDto(alb); } AlbumDto obj = null; for (var i = parents.Count - 1; i >= 0; i--) { obj = _treeList.Where(x => x.Id == parents[i]).First(); tlwAlbums.Expand(obj); } _searchedSong = string.IsNullOrEmpty(songSearched) ? "" : songSearched.ToLower(); obj = _treeList.Where(x => x.Id == node.Id).FirstOrDefault(); if (obj != null) { tlwAlbums.SelectedObject = obj; tlwAlbums.FocusedObject = obj; tlwAlbums.EnsureModelVisible(obj); } }
private void ValidateAlbum(AlbumDto albumToValidate) { if (albumToValidate.Price >= 100) { _validationProvider.Validate(albumToValidate); } }
public async Task <IEnumerable <AlbumDto> > SearchSpotifyAlbums(string keyword) { var auth = new CredentialsAuth(ClientId, SecretId); var token = await auth.GetToken(); var api = new SpotifyWebAPI() { TokenType = token.TokenType, AccessToken = token.AccessToken }; var searchItem = await api.SearchItemsAsync(keyword, SearchType.Album); var albumsToReturn = new List <AlbumDto>(); foreach (var album in searchItem.Albums.Items) { var albumToReturn = new AlbumDto { Artist = album.Artists[0].Name, Name = album.Name, Id = album.Id, UserId = 1, CoverUrl = album.Images[0].Url, Year = album.ReleaseDate.Substring(0, 4) }; albumsToReturn.Add(albumToReturn); } return(albumsToReturn); }
public ActionResult AddOrEdit(AlbumDto album) { try { if (album.ImageUpload != null) { GenerateImagePath(album); } if (album.AlbumID == 0) { albumRepository.AddAlbum(mapper.Map <Album>(album)); } else { albumRepository.EditAlbum(mapper.Map <Album>(album)); } return(Json(new { success = true, html = RazorToString.RenderRazorView(this, "GetAll", mapper.Map <IEnumerable <AlbumDto> >(albumRepository.GetAllAlbums())), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private static AlbumDto ConfigureAlbumTable(int galleryId, GspContext ctx) { // Create the root album if necessary. var rootAlbumDto = (from a in ctx.Albums where a.FKGalleryId == galleryId && a.AlbumParentId == 0 select a).FirstOrDefault(); if (rootAlbumDto == null) { rootAlbumDto = new AlbumDto { FKGalleryId = galleryId, AlbumParentId = 0, Title = "All albums", DirectoryName = String.Empty, Summary = "Welcome to Gallery Server Pro!", ThumbnailMediaObjectId = 0, Seq = 0, DateAdded = DateTime.Now, CreatedBy = "System", LastModifiedBy = "System", DateLastModified = DateTime.Now, OwnedBy = String.Empty, OwnerRoleName = String.Empty, IsPrivate = false }; ctx.Albums.Add(rootAlbumDto); ctx.SaveChanges(); } return(rootAlbumDto); }
public Response <AlbumDto> FindById(int id) { if (id <= 0) { return(new Response <AlbumDto>(false, "Id must be grater than 0", null)); } AlbumDto response = new AlbumDto(); try { using (musicDBEntities db = new musicDBEntities()) { Album album = db.Album.Find(id); response.Id = album.album_id; response.Name = album.name; response.Released = album.relesed; } return(new Response <AlbumDto>(true, "Element was found", response)); } catch (Exception e) { if (e.InnerException == null) { return(new Response <AlbumDto>(false, "Somethig was wrong. Exception: " + e.Message, null)); } else { return(new Response <AlbumDto>(false, "Somethig was wrong. Exception: " + e.InnerException.InnerException.Message, null)); } } }
//bak public async Task <BaseResponse <string> > Delete(AlbumDto album) { BaseResponse <string> baseResponse = new BaseResponse <string>(); var files = album.Images; if (files.Count > 0) { string pathBuild = Path.Combine(Directory.GetCurrentDirectory(), "Uploads\\"); foreach (var item in files) { string[] fileName = item.Path.Split("Uploads/"); pathBuild = Path.Combine(pathBuild, fileName[fileName.Length - 1]); var deletedFileFromStorage = _filesService.DeleteFile(pathBuild); var deletedFile = await _filesService.Delete(new FilesDto { Id = item.Id, Path = item.Path }); } var result = await _albumRepository.DeleteById(album.Id); baseResponse.Result = result > 0 ? "Success Delete" : null; } else { var result = await _albumRepository.DeleteById(album.Id); baseResponse.Result = result > 0 ? "Success Delete" : null; } return(baseResponse); }
public async Task <AlbumDto> GetByName(string name) { Album album = _database.AlbumRepository.GetByName(name); AlbumDto albumDto = _mapper.Map <Album, AlbumDto>(album); return(await GetFullInfoDto(albumDto)); }
public AlbumDto Post([FromBody] AlbumDto model) { var data = mapper.Map <Album>(model); albumRepo.Insert(data); return(mapper.Map <AlbumDto>(data)); }
public void UpdateCustomer(int id, AlbumDto albumDto) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var albumInDb = _context.Albums.SingleOrDefault(a => a.Id == id); if (albumInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } Mapper.Map <AlbumDto, Album>(albumDto, albumInDb); albumInDb.Title = albumDto.Title; albumInDb.Price = albumDto.Price; albumInDb.ImageURL = albumDto.ImageURL; albumInDb.Artist = albumDto.Artist; albumInDb.Stock = albumDto.Stock; albumInDb.Genre = albumDto.Genre; albumInDb.Rating = albumDto.Rating; _context.SaveChanges(); }
public void Create(AlbumDto item) { if (item == null) { throw new ArgumentNullException(); } var client = db.ClientProfiles.Get(item.ClientProfileID); if (client == null) { throw new ClientNotFoundException("User is not found"); } var newAlbum = new Album() { Title = item.Title, Description = item.Description, ClientProfileID = client.ClientProfileID, ClientProfile = client }; db.Albums.Create(newAlbum); db.SaveAsync(); }
// ShareAlbum <albumId> <username> <permission> public string Execute(string[] data) { int albumId = int.Parse(data[0]); AlbumDto albumDTO = albumService.ById <AlbumDto>(albumId); if (albumDTO == null) { throw new ObjectNotFoundException(typeof(Album).Name, data[0]); } string username = data[1]; UserRolesDto userDTO = userService.ByUsername <UserRolesDto>(username); if (userDTO == null || userDTO.IsDeleted == true) { throw new ObjectNotFoundException(typeof(User).Name, username); } if (!Enum.TryParse(data[2], true, out Role role)) { throw new InvalidPermissionException(); } string permission = role.ToString(); AlbumRoleDto alreadySharedAlbum = userDTO.Permissions .FirstOrDefault(p => p.AlbumName == albumDTO.Name); if (alreadySharedAlbum != null && alreadySharedAlbum.Permission == permission) { throw new PermissionAlreadyGrantedException(username, permission, albumDTO.Name); } AlbumRole albumRole = albumRoleService.PublishAlbumRole(albumId, userDTO.Id, permission); return(String.Format(SuccessMessage, username, albumDTO.Name, permission)); }
private async Task <AlbumDto> GetFullInfoDto(AlbumDto albumDto) { Artist artist = await _database.ArtistRepository.GetById(albumDto.ArtistId); albumDto.ArtistName = artist.Name; return(albumDto); }
/// <summary> /// Verify there is a UI template/album mapping for the root album in the current gallery, creating them /// if necessary. /// </summary> /// <param name="rootAlbum">The root album.</param> private static void ConfigureUiTemplateAlbumTable(AlbumDto rootAlbum) { using (var repoUiTmpl = new UiTemplateRepository()) { using (var repoUiTmplA = new UiTemplateAlbumRepository(repoUiTmpl.Context)) { // Make sure each template category has at least one template assigned to the root album. // We do this with a union of two queries: // 1. For categories where there is at least one album assignment, determine if at least one of // those assignments is the root album. // 2. Find categories without any albums at all (this is necessary because the SelectMany() in the first // query won't return any categories that don't have related records in the template/album table). var dtos = repoUiTmpl.Where(t => t.FKGalleryId == rootAlbum.FKGalleryId) .SelectMany(t => t.TemplateAlbums, (t, tt) => new { t.TemplateType, tt.FKAlbumId }) .GroupBy(t => t.TemplateType) .Where(t => t.All(ta => ta.FKAlbumId != rootAlbum.AlbumId)) .Select(t => t.Key) .Union(repoUiTmpl.Where(t => t.FKGalleryId == rootAlbum.FKGalleryId).GroupBy(t => t.TemplateType).Where(t => t.All(t2 => !t2.TemplateAlbums.Any())).Select(t => t.Key)) ; foreach (var dto in dtos) { // We have a template type without a root album. Find the default template and assign that one. var dto1 = dto; repoUiTmplA.Add(new UiTemplateAlbumDto() { FKUiTemplateId = repoUiTmpl.Where(t => t.FKGalleryId == rootAlbum.FKGalleryId && t.TemplateType == dto1 && t.Name.Equals("default", StringComparison.OrdinalIgnoreCase)).First().UiTemplateId, FKAlbumId = rootAlbum.AlbumId }); } repoUiTmplA.Save(); } } }
public async Task <AlbumDto> CreateAsync(AlbumDto item) { var result = _context.Albums.Add(AlbumConverter.Convert(item)); await _context.SaveChangesAsync(); return(AlbumConverter.Convert(result.Entity)); }
public void Create(AlbumDto albumDto, Guid requestorId) { if ((_userRepository.GetUserById(requestorId)).Roles[0].Name.Equals("Subscriber") || (_userRepository.GetUserById(requestorId)).Roles[0].Name.Equals("Admin")) { _albumRepository.AddAlbum(AlbumAdapter.BuildAlbum(albumDto), albumDto.UsersWithAccess); } }
public AlbumDto GetAlbum(int wallId) { Wall wall = pageManager.GetWall(wallId); AlbumDto albumDto = wallMapper.GetAlbumDto(wall); return(albumDto); }
public async Task <AlbumDto> UpdateAlbumAsync(Guid id, [FromBody] AlbumDto albumDto) { _logger?.LogDebug("'{0}' has been invoked", MethodBase.GetCurrentMethod().DeclaringType); var response = new AlbumDto(); if (ModelState.IsValid) { try { _logger?.LogInformation("The UpdateAlbumAsync have been retrieved successfully."); var album = await _albumRepository.UpdateAlbumAsync(_mapper.Map <Album>(albumDto)); return(_mapper.Map <AlbumDto>(album)); } catch (Exception ex) { _logger?.LogCritical("There was an error on '{0}' invocation: {1}", MethodBase.GetCurrentMethod().DeclaringType, ex); return(response = new AlbumDto { ErrorMessage = new string[] { ex.Message } }); } } else { return response = new AlbumDto { ErrorMessage = new string[] { "ModelState is not valid: " + ModelState.ToString() } } }; }
public async Task <IActionResult> Update(Guid artistId, Guid id, [FromBody] AlbumDto model) { try { var album = service.GetAlbum(id); if (album == null) { return(NotFound()); } if (album.Artist.Id != artistId) { return(BadRequest("Album not in specofic artist container")); } mapper.Map(model, album); if (await service.SaveAllAsync()) { return(Ok(mapper.Map <AlbumDto>(album))); } } catch (Exception) { } return(BadRequest("Please try again")); }
public async Task <IActionResult> Create(Guid artistId, [FromBody] AlbumDto model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var list = service.GetArtist(artistId); if (list == null) { return(BadRequest("Could not find Artist")); } var album = mapper.Map <Album>(model); // adding to Album model service.Add(album); if (await service.SaveAllAsync()) { var url = Url.Link("GetAlbum", new { artistId = list.Id, id = album.Id }); return(Created(url, mapper.Map <AlbumDto>(album))); } } catch (Exception) { } return(BadRequest("Please try again")); }
public async Task <IActionResult> PutAlbum(int id, AlbumDto albumDto) { if (!this.ModelState.IsValid) { return(this.BadRequest()); } albumDto.Id = id; var result = await this.albumsService.Update(id, albumDto); if (result == false) { return(this.BadRequest("No such album")); } var isQunie = this.albumsService.IsUnique(albumDto.Name, id); if (isQunie == false) { return(this.BadRequest("There is already album with that name in the database")); } return(CreatedAtAction("GetAlbum", new { id = id }, albumDto)); }
public Response <IEnumerable <AlbumDto> > SelectAll() { List <AlbumDto> response = new List <AlbumDto>(); try { using (musicDBEntities db = new musicDBEntities()) { List <Album> albums = db.Album.ToList(); foreach (Album album in albums) { AlbumDto aux = new AlbumDto(); aux.Id = album.album_id; aux.Name = album.name; aux.Released = album.relesed; response.Add(aux); } } return(new Response <IEnumerable <AlbumDto> >(true, response.Count + " albums found", response)); } catch (Exception e) { if (e.InnerException == null) { return(new Response <IEnumerable <AlbumDto> >(false, "Somethig was wrong. Exception: " + e.Message, response)); } else { return(new Response <IEnumerable <AlbumDto> >(false, "Somethig was wrong. Exception: " + e.InnerException.InnerException.Message, response)); } } }
private static AlbumDto ConfigureAlbumTable(int galleryId, GspContext ctx) { // Create the root album if necessary. var rootAlbumDto = (from a in ctx.Albums where a.FKGalleryId == galleryId && a.AlbumParentId == 0 select a).FirstOrDefault(); if (rootAlbumDto == null) { rootAlbumDto = new AlbumDto { FKGalleryId = galleryId, AlbumParentId = 0, Title = "All albums", DirectoryName = String.Empty, Summary = "Welcome to Gallery Server Pro!", ThumbnailMediaObjectId = 0, Seq = 0, DateAdded = DateTime.Now, CreatedBy = "System", LastModifiedBy = "System", DateLastModified = DateTime.Now, OwnedBy = String.Empty, OwnerRoleName = String.Empty, IsPrivate = false }; ctx.Albums.Add(rootAlbumDto); ctx.SaveChanges(); } return rootAlbumDto; }
public ICollection <AlbumDto> GetAllAlbums() { var albums = _albumRepository.GetAll(); if (!albums.IsNullOrEmpty()) { ICollection <AlbumDto> albumsDto = new LinkedList <AlbumDto>(); AlbumDto albumDto = null; foreach (Album album in albums) { albumDto = new AlbumDto(album.Id, album.Title, album.DateReleased); if (album.ArtistAlbums.Count > 0) { foreach (ArtistAlbum artistAlbum in album.ArtistAlbums) { albumDto.Artists.Add(new ArtistDto(artistAlbum.Artist.Id, artistAlbum.Artist.DisplayName, artistAlbum.Artist.Firstname, artistAlbum.Artist.Lastname, new ArtistDetailsDto { StageName = artistAlbum.Artist.ArtistDetails.StageName }, artistAlbum.Artist.ConcurrencyStamp)); } } albumsDto.Add(albumDto); } return(albumsDto); } return(null); }
public async Task <int> AddAsync(AlbumDto input) { var existsWithName = this.repository.All() .Where(x => x.Name == input.Name) .FirstOrDefault(); if (existsWithName != null) { return(-1); } var album = new Album() { Name = input.Name, ReleaseDate = input.ReleaseDate, ProducerId = input.ProducerId }; await this.repository.AddAsync(album); await this.repository.SaveChangesAsync(); //var albumReuslt = this.repository.All() // .Where(x => x.Name == album.Name) // .FirstOrDefault(); return(album.Id); }
public Response <int> Insert(AlbumDto newObject) { if (newObject == null) { return(new Response <int>(false, "Album cannot be null", -1)); } Album album = new Album { name = newObject.Name, relesed = newObject.Released }; try { using (musicDBEntities db = new musicDBEntities()) { db.Album.Add(album); db.SaveChanges(); } return(new Response <int>(true, "Album was inserted in DB", album.album_id)); } catch (Exception e) { if (e.InnerException == null) { return(new Response <int>(false, "Somethig was wrong. Exception: " + e.Message, -1)); } else { return(new Response <int>(false, "Somethig was wrong. Exception: " + e.InnerException.InnerException.Message, -1)); } } }
public AlbumDto Update([FromBody] AlbumDto model) { var album = mapper.Map <Album>(model); albumRepo.Update(album); return(mapper.Map <AlbumDto>(album)); }
public ActionResult Index(AlbumDto albumToCreate) { //try //{ // _albumService.CreateAlbum(new AlbumDto() { Price = 101 }); //} //catch (ValidationException ex) //{ // this.ModelState.AddModelErrors(ex); // return View(); //} if (ModelState.IsValid) { _albumService.CreateAlbum(albumToCreate); return RedirectToAction("Index"); } return View(albumToCreate); }
// PUT api/Albums/5 public HttpResponseMessage PutAlbum(int id, AlbumDto album) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } var albumToUpdate = db.Albums.FirstOrDefault(a => a.AlbumId == id); if (albumToUpdate != null && album != null) { albumToUpdate.UpdateWith(new Album { AlbumTitle = album.AlbumTitle, AlbumYear = album.AlbumYear, Producer = album.Producer }); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } db.Entry(albumToUpdate).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }
private IEnumerable<PhotoDto> GetPhotosToAdd(IEnumerable<PhotoDto> photos, AlbumDto album) { return photos.Where(p => { bool canAdd = false; if (album.Privacy.Level == PrivacyLevel.Private) canAdd = p.Privacy.OnlyLoggedIn ? album.Privacy.OnlyLoggedIn : true; else if (album.Privacy.Level == PrivacyLevel.Group) if (p.Privacy.Level == PrivacyLevel.Public || p.Privacy.Level == PrivacyLevel.Hidden || ((ImageHoster.CQRS.ReadModel.Dto.GroupPrivacy)album.Privacy).GroupsEligible.IsSubsetOf(((ImageHoster.CQRS.ReadModel.Dto.GroupPrivacy)p.Privacy).GroupsEligible)) canAdd = p.Privacy.OnlyLoggedIn ? album.Privacy.OnlyLoggedIn : true; else { } else if (album.Privacy.Level == PrivacyLevel.Hidden || album.Privacy.Level == PrivacyLevel.Public) if (p.Privacy.Level == PrivacyLevel.Public || p.Privacy.Level == PrivacyLevel.Hidden) canAdd = p.Privacy.OnlyLoggedIn ? album.Privacy.OnlyLoggedIn : true; return canAdd; }); }
public void CreateAlbum(AlbumDto dto) { //ValidateAlbum(dto); _validationProvider.Validate(dto); }
public ActionResult Index() { var model = new AlbumDto() { Price = 101 }; return View(model); }
private bool CanSeePhoto(AlbumDto dto, Guid userid) { if (userid == dto.Owner.Id) return true; else return dto.Privacy.CanSee(userid); }
/// <summary> /// Persist the specified album to the data store. Return the ID of the album. /// </summary> /// <param name="album">An instance of <see cref="IAlbum"/> to persist to the data store.</param> /// <returns> /// Return the ID of the album. If this is a new album and a new ID has been /// assigned, then this value has also been assigned to the ID property of the object. /// </returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="album" /> is null.</exception> public override int Album_Save(IAlbum album) { if (album == null) throw new ArgumentNullException("album"); using (GspContext ctx = new GspContext()) { if (album.IsNew) { AlbumDto aDto = new AlbumDto { FKGalleryId = album.GalleryId, AlbumParentId = album.Parent.Id, Title = album.Title, DirectoryName = album.DirectoryName, Summary = album.Summary, ThumbnailMediaObjectId = album.Thumbnail.MediaObjectId, Seq = album.Sequence, DateStart = (album.DateStart > DateTime.MinValue ? album.DateStart : (DateTime?)null), DateEnd = (album.DateEnd > DateTime.MinValue ? album.DateEnd : (DateTime?)null), CreatedBy = album.CreatedByUserName, DateAdded = album.DateAdded, LastModifiedBy = album.LastModifiedByUserName, DateLastModified = album.DateLastModified, OwnedBy = album.OwnerUserName, OwnerRoleName = album.OwnerRoleName, IsPrivate = album.IsPrivate }; ctx.Albums.Add(aDto); ctx.SaveChanges(); if (album.Id != aDto.AlbumId) album.Id = aDto.AlbumId; // Return newly created album ID. return aDto.AlbumId; } else { AlbumDto aDto = ctx.Albums.Find(album.Id); if (aDto != null) { aDto.FKGalleryId = album.GalleryId; aDto.AlbumParentId = album.Parent.Id; aDto.Title = album.Title; aDto.DirectoryName = album.DirectoryName; aDto.Summary = album.Summary; aDto.ThumbnailMediaObjectId = album.ThumbnailMediaObjectId; aDto.Seq = album.Sequence; aDto.DateStart = (album.DateStart > DateTime.MinValue ? album.DateStart : (DateTime?)null); aDto.DateEnd = (album.DateEnd > DateTime.MinValue ? album.DateEnd : (DateTime?)null); aDto.LastModifiedBy = album.LastModifiedByUserName; aDto.DateLastModified = album.DateLastModified; aDto.OwnedBy = album.OwnerUserName; aDto.OwnerRoleName = album.OwnerRoleName; aDto.IsPrivate = album.IsPrivate; ctx.SaveChanges(); } return album.Id; } } }