public void Add(Album item) { using (var db = new PhotoExplorationContext()) { db.Albums.Add(item); db.SaveChanges(); } }
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(); } }
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(); } }
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")); } }