public int Create(AlbumDTO item) { Mapper.CreateMap<AlbumDTO, Album>(); int result = Database.Albums.Create(Mapper.Map<AlbumDTO, Album>(item)).Id; Database.Save(); return result; }
public void Update(AlbumDTO item) { Mapper.CreateMap<AlbumDTO, Album>(); Database.Albums.Update(Mapper.Map<AlbumDTO, Album>(item)); Database.Save(); }
public void CreateAlbum(AlbumDTO newObj) { newObj.created = DateTime.Now; newObj.modified = DateTime.Now; _albumSvc.Create(newObj); }
public void DeleteAlbum(AlbumDTO newObj) { // change not nullable fields only }
public void ManageAlbum(AlbumDTO album) { album.modified = DateTime.Now; _albumSvc.Update(album); var names = album.picturesName.ToArray(); UserDTO user = _userSvc.Get(album.userId); string rootPath = HttpContext.Current.Request.MapPath("~/Temp/"); string tempDirectoryPath = Path.Combine(rootPath, user.email); rootPath = HttpContext.Current.Request.MapPath("~/Pictures/"); string userDirectoryPath = Path.Combine(rootPath, user.email); if (!Directory.Exists(userDirectoryPath)) { string standartImageDirectoryPath = Path.Combine(userDirectoryPath, "Standart"); string mediumImageDirectoryPath = Path.Combine(userDirectoryPath, "Medium"); string smallImageDirectoryPath = Path.Combine(userDirectoryPath, "Small"); Directory.CreateDirectory(userDirectoryPath); Directory.CreateDirectory(standartImageDirectoryPath); Directory.CreateDirectory(mediumImageDirectoryPath); Directory.CreateDirectory(smallImageDirectoryPath); } if (Directory.Exists(tempDirectoryPath)) { var httpRequest = HttpContext.Current.Request; if (names.Length > 0) { foreach (string name in names) { try { if (!File.Exists(tempDirectoryPath + "/Standart/" + name)) { using (FileStream fs = File.Create(tempDirectoryPath + "/Standart/" + name)) { } } File.Move(tempDirectoryPath + "/Standart/" + name, userDirectoryPath + "/Standart/" + name); File.Move(tempDirectoryPath + "/Medium/" + name, userDirectoryPath + "/Medium/" + name); File.Move(tempDirectoryPath + "/Small/" + name, userDirectoryPath + "/Small/" + name); } catch (Exception e) { throw new Exception("file has not been moved",e.InnerException); } _pictureSvc.Create(new PictureDTO { urlStandart = Convert.ToString("Pictures/" + user.email + "/Standart/" + name), urlMedium = Convert.ToString("Pictures/" + user.email + "/Medium/" + name), urlSmall = Convert.ToString("Pictures/" + user.email + "/Small/" + name), albumId = album.id, userId = album.userId, likes = 0 }); } } } else { throw new Exception(); } }