示例#1
0
        public ActionResult Create(Models.PhotoModel photo, HttpPostedFileBase file)
        {
            using (var context = new MvcDataContext())
            {
                // TODO: Add insert logic here

                if (photo != null)
                {
                    var phot = new PhotoClass();



                    phot.PhotoName = file.FileName;
                    phot.PhotoId   = Guid.NewGuid();
                    phot.Date      = DateTime.Now;
                    Path.GetFileName(file.FileName);
                    file.SaveAs(Path.Combine(Server.MapPath("~/Pictures"), file.FileName));
                    context.photo.Add(phot);
                    context.SaveChanges();
                }


                return(View());
            }
        }
示例#2
0
 public PhotoClass GetPhoto(Guid id)
 {
     using (var context = new MvcDataContext())
     {
         return(context.photo.Include("Comment").FirstOrDefault(p => p.PhotoId == id));
     }
 }
示例#3
0
 public ActionResult Comment()
 {
     using (var context = new MvcDataContext())
     {
     }
     return(View());
 }
示例#4
0
 public AlbumClass ShowAlbum(Guid id)
 {
     using (var context = new MvcDataContext())
     {
         return(context.album.Include("Comment").FirstOrDefault(x => x.AlbumId == id));
     }
 }
示例#5
0
 public AlbumEntityModel GetPhoto(Guid id)
 {
     using (var context = new MvcDataContext())
     {
         return(context.AlbumEntityModels.Include("Comment").FirstOrDefault(x => x.AlbumId == id));
     }
 }
示例#6
0
 public List <AlbumClass> GetAllAlbums()
 {
     using (var context = new MvcDataContext())
     {
         var albums = context.album.Include("Comment").Include("Photo").ToList();
         return(albums);
     }
 }
示例#7
0
 public List <PhotoClass> GetAllPhoto()
 {
     using (var context = new MvcDataContext())
     {
         var photos = context.photo.Include("Comment").ToList();
         return(photos);
     }
 }
示例#8
0
 public List <PhotoEntityModel> GetPhotos()
 {
     using (var context = new MvcDataContext())
     {
         var photos = context.PhotoEntityModels.Include("Comment").ToList();
         return(photos);
     }
 }
示例#9
0
 public List <AlbumEntityModel> GetAlbum()
 {
     using (var context = new MvcDataContext())
     {
         var albums = context.AlbumEntityModels.Include("Comment").Include("Photo").ToList();
         return(albums);
     }
 }
示例#10
0
        // GET: Gallery/Delete/5
        public ActionResult Delete(Guid id)
        {
            using (var context = new MvcDataContext())
            {
                var pht = context.photo.Single(x => x.PhotoId == id);

                return(View());
            }
        }
示例#11
0
 public void DeletePhoto(PhotoClass photo)
 {
     using (var context = new MvcDataContext())
     {
         var photoToDelete = context.photo.Include("Comment").FirstOrDefault(p => p.PhotoId == photo.PhotoId);
         context.photo.Remove(photoToDelete);
         context.photo.AddOrUpdate(photoToDelete);
         context.SaveChanges();
     }
 }
示例#12
0
 public void AddNewAlbumComment(Guid albumid, CommentEntityModel newalbumComment)
 {
     using (var context = new MvcDataContext())
     {
         var albumEnt = context.AlbumEntityModels.FirstOrDefault(x => x.AlbumId == albumid);
         albumEnt.Comment.Add(newalbumComment);
         context.AlbumEntityModels.AddOrUpdate(albumEnt);
         context.SaveChanges();
     }
 }
示例#13
0
 public void AddNewPhotoComment(Guid photoid, CommentEntityModel newphotoComment)
 {
     using (var context = new MvcDataContext())
     {
         var photoEnt = context.PhotoEntityModels.FirstOrDefault(x => x.PhotoId == photoid);
         photoEnt.Comment.Add(newphotoComment);
         context.PhotoEntityModels.AddOrUpdate(photoEnt);
         context.SaveChanges();
     }
 }
示例#14
0
 public void AddNewPhotoComment(Guid photoid, CommentClass newphotoComment)
 {
     using (var context = new MvcDataContext())
     {
         var photoentity = context.photo.FirstOrDefault(p => p.PhotoId == photoid);
         photoentity.PComment.Add(newphotoComment);
         context.photo.AddOrUpdate(photoentity);
         context.SaveChanges();
     }
 }
示例#15
0
 public void AddNewAlbumComment(Guid albumid, CommentClass newalbumCommet)
 {
     using (var context = new MvcDataContext())
     {
         var albumentity = context.album.FirstOrDefault(a => a.AlbumId == albumid);
         albumentity.Comment.Add(newalbumCommet);
         context.album.AddOrUpdate(albumentity);
         context.SaveChanges();
     }
 }
示例#16
0
 public void DeleteAlbum(AlbumEntityModel album)
 {
     using (var context = new MvcDataContext())
     {
         var deleteAlbum =
             context.AlbumEntityModels.Include("Comment").FirstOrDefault(x => x.AlbumId == album.AlbumId);
         context.AlbumEntityModels.Remove(deleteAlbum);
         context.AlbumEntityModels.AddOrUpdate(deleteAlbum);
         context.SaveChanges();
     }
 }
示例#17
0
 public void DeletePhoto(PhotoEntityModel photo)
 {
     using (var context = new MvcDataContext())
     {
         var deletePhoto =
             context.PhotoEntityModels.Include("Comment").FirstOrDefault(x => x.PhotoId == photo.PhotoId);
         context.PhotoEntityModels.Remove(deletePhoto);
         context.PhotoEntityModels.AddOrUpdate(deletePhoto);
         context.SaveChanges();
     }
 }
示例#18
0
 public ActionResult Comment(string commentphoto)
 {
     using (var context = new MvcDataContext())
     {
         var NewComment = new CommentClass();
         NewComment.CommentOnPhoto = commentphoto;
         context.comment.Add(NewComment);
         context.SaveChanges();
     }
     return(View("PhotList"));
 }
示例#19
0
 public PhotoEntityModel AddCommentPhoto(Guid id, string photoComment)
 {
     using (var context = new MvcDataContext())
     {
         var photocomment = context.PhotoEntityModels.Include("Comment").FirstOrDefault(x => x.PhotoId == id);
         photocomment.Comment.Add(new CommentEntityModel {
             Id = Guid.NewGuid(), CommentPhoto = photoComment
         });
         context.PhotoEntityModels.AddOrUpdate(photocomment);
         context.SaveChanges();
         return(photocomment);
     }
 }
示例#20
0
 public void AddPhoto(PhotoEntityModel newphoto)
 {
     using (var context = new MvcDataContext())
     {
         PhotoEntityModel photo = new PhotoEntityModel();
         photo.PhotoId   = newphoto.PhotoId;
         photo.PhotoName = newphoto.PhotoName;
         photo.Comment   = newphoto.Comment;
         context.PhotoEntityModels.Add(photo);
         context.PhotoEntityModels.AddOrUpdate(photo);
         context.SaveChanges();
     }
 }
示例#21
0
 public void AddPhotoToAlbum(IEnumerable <Guid> photos, Guid albumID)
 {
     using (var context = new MvcDataContext())
     {
         var albumToAddIn = context.album.FirstOrDefault(x => x.AlbumId == albumID);
         foreach (var item in photos)
         {
             albumToAddIn.Photo.Add(context.photo.Include("Comment").FirstOrDefault(x => x.PhotoId == item));
         }
         context.album.AddOrUpdate(albumToAddIn);
         context.SaveChanges();
     }
 }
示例#22
0
 public AlbumClass AddCommentToAlbum(Guid id, string albumComment)
 {
     using (var context = new MvcDataContext())
     {
         var albumtocomment = context.album.Include("Comment").FirstOrDefault(x => x.AlbumId == id);
         albumtocomment.Comment.Add(new CommentClass {
             Id = Guid.NewGuid(), CommentOnAlbum = albumComment
         });
         context.album.AddOrUpdate(albumtocomment);
         context.SaveChanges();
         return(albumtocomment);
     }
 }
示例#23
0
 public void AddPhoto(PhotoClass newphoto)
 {
     using (var context = new MvcDataContext())
     {
         PhotoClass photo = new PhotoClass();
         photo.PhotoId   = newphoto.PhotoId;
         photo.PhotoName = newphoto.PhotoName;
         photo.PComment  = newphoto.PComment;
         context.photo.Add(photo);
         context.photo.AddOrUpdate(photo);
         context.SaveChanges();
     }
 }
示例#24
0
 public void AddAlbum(AlbumEntityModel newalbum)
 {
     using (var context = new MvcDataContext())
     {
         AlbumEntityModel album = new AlbumEntityModel();
         album.AlbumId   = newalbum.AlbumId;
         album.AlbumName = newalbum.AlbumName;
         album.Comment   = newalbum.Comment;
         context.AlbumEntityModels.Add(album);
         context.AlbumEntityModels.AddOrUpdate(album);
         context.SaveChanges();
     }
 }
示例#25
0
 public AlbumEntityModel AddComment(Guid id, string albumComment)
 {
     using (var context = new MvcDataContext())
     {
         var albumcomment = context.AlbumEntityModels.Include("Comment").FirstOrDefault(x => x.AlbumId == id);
         albumcomment.Comment.Add(new CommentEntityModel {
             Id = Guid.NewGuid(), CommentAlbum = albumComment
         });
         context.AlbumEntityModels.AddOrUpdate(albumcomment);
         context.SaveChanges();
         return(albumcomment);
     }
 }
示例#26
0
 public PhotoClass AddCommentToPhoto(Guid id, string photoComment)
 {
     using (var context = new MvcDataContext())
     {
         var phototocomment = context.photo.Include("Comment").FirstOrDefault(x => x.PhotoId == id);
         phototocomment.PComment.Add(new CommentClass {
             Id = Guid.NewGuid(), CommentOnPhoto = photoComment
         });
         context.photo.AddOrUpdate(phototocomment);
         context.SaveChanges();
         return(phototocomment);
     }
 }
示例#27
0
        public ActionResult Delete(Guid id, FormCollection collection)
        {
            using (var context = new MvcDataContext())
            {
                var i = context.photo.Single(x => x.PhotoId == id);

                context.photo.Remove(i);
                context.SaveChanges();
            }
            // TODO: Add delete logic here

            return(RedirectToAction("PhotList"));
        }
示例#28
0
 public void AddNewAlbum(AlbumClass newalbum)
 {
     using (var context = new MvcDataContext())
     {
         AlbumClass album = new AlbumClass();
         album.AlbumId   = newalbum.AlbumId;
         album.AlbumName = newalbum.AlbumName;
         album.Comment   = newalbum.Comment;
         //album.Photo = newalbum.Photo;
         context.album.Add(album);
         context.album.AddOrUpdate(album);
         context.SaveChanges();
     }
 }
示例#29
0
        public ActionResult CreateUser(Guid id, AccountClass user)
        {
            using (var context = new MvcDataContext())
            {
                var NewUser = new AccountClass();
                NewUser.FirstName = user.FirstName;
                NewUser.LastName  = user.LastName;
                NewUser.Email     = user.Email;
                NewUser.Password  = user.Password;
                NewUser.Id        = Guid.NewGuid();
                context.account.Add(NewUser);
                context.SaveChanges();
            }
            // TODO: Add insert logic here

            return(View());
        }
示例#30
0
 public DatosController(MvcDataContext context)
 {
     _context = context;
 }