コード例 #1
0
ファイル: PhotoMapper.cs プロジェクト: CashmereBob/MVC
 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
     });
 }
コード例 #2
0
        public ActionResult Edit(EditPhotoViewModels photo, FormCollection collection)
        {
            Photo model = PhotoMapper.MapEditPhotoViewModel(photo);

            try
            {
                photoRepository.UdaptePhoto(model);
                return(Content(photo.Name));
            }
            catch
            {
                return(Content("Error"));
            }
        }
コード例 #3
0
ファイル: PhotoMapper.cs プロジェクト: CashmereBob/MVC
        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);
        }
コード例 #4
0
        // 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());
            }
        }