コード例 #1
0
        public void Add(Album item)
        {
            using (var db = new PhotoExplorationContext())
            {
                db.Albums.Add(item);

                db.SaveChanges();
            }
        }
コード例 #2
0
        public void Add(User item)
        {
            using (var db = new PhotoExplorationContext())
            {
                db.Users.Add(new User
                {
                    Id       = item.Id,
                    Email    = item.Email,
                    Name     = item.Name,
                    Password = item.Password,
                    Admin    = false
                });

                db.SaveChanges();
            }
        }
コード例 #3
0
        public void Add(Comment item)
        {
            using (var db = new PhotoExplorationContext())
            {
                db.Comments.Add(new Comment
                {
                    Id      = item.Id,
                    Text    = item.Text,
                    Date    = item.Date,
                    PhotoId = item.PhotoId,
                    UserId  = item.UserId
                });

                db.SaveChanges();
            }
        }
コード例 #4
0
        public ActionResult DeleteCommentConfirmed(Guid id)
        {
            using (var db = new PhotoExplorationContext())
            {
                var comment = db.Comments.Include(i => i.Photo).FirstOrDefault(x => x.Id == id);
                if (comment == null)
                {
                    return(new HttpNotFoundResult());
                }
                db.Comments.Remove(comment);

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }