Esempio n. 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());
            }
        }
Esempio n. 2
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();
     }
 }
Esempio n. 3
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();
     }
 }
Esempio n. 4
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();
     }
 }
Esempio n. 5
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();
     }
 }
Esempio n. 6
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();
     }
 }
Esempio n. 7
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"));
 }
Esempio n. 8
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();
     }
 }
Esempio n. 9
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();
     }
 }
Esempio n. 10
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);
     }
 }
Esempio n. 11
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();
     }
 }
Esempio n. 12
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);
     }
 }
Esempio n. 13
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();
     }
 }
Esempio n. 14
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();
     }
 }
Esempio n. 15
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);
     }
 }
Esempio n. 16
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"));
        }
Esempio n. 17
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);
     }
 }
Esempio n. 18
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();
     }
 }
Esempio n. 19
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();
     }
 }
Esempio n. 20
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());
        }