internal static Photo MapEditPhotoViewModel(EditPhotoViewModels photo) { return(new Photo { Description = photo.Description, Name = photo.Name, Id = photo.Id, AlbumID = photo.AlbumId != null ? photo.AlbumId : Guid.Empty }); }
public ActionResult Edit(EditPhotoViewModels photo, FormCollection collection) { Photo model = PhotoMapper.MapEditPhotoViewModel(photo); try { photoRepository.UdaptePhoto(model); return(Content(photo.Name)); } catch { return(Content("Error")); } }
internal static EditPhotoViewModels MapEditPhotoViewModel(Photo model) { var photo = new EditPhotoViewModels(); photo.Name = model.Name; photo.Description = model.Description; photo.Path = model.Path; photo.Id = model.Id; model.Comments.ToList().ForEach(x => photo.Comments.Add(new CommentViewModel { id = x.Id, comment = x.Content })); return(photo); }
// GET: User/Edit/Edit/5 public ActionResult Edit(EditPhotoViewModels photo) { Photo model = photoRepository.GetPhotoFromDbById(photo.Id); photo = PhotoMapper.MapEditPhotoViewModel(model); photo.AlbumId = model.AlbumID != null ? (Guid)model.AlbumID : Guid.Empty; var albums = albumRepository.GettAllAlbumsByUserID(userID); photo.Albums.Add(new SelectListItem { Text = "Uncategorized", Value = Guid.Empty.ToString() }); albums.ForEach(x => photo.Albums.Add(new SelectListItem { Text = x.Name, Value = x.Id.ToString() })); if (model.UserID == userID) { return(View(photo)); } else { return(View()); } }