public ActionResult Create([Bind(Include = "PostId,Post,UserId,PostTime")] Posts posts) { if (ModelState.IsValid) { db.Posts.Add(posts); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(posts)); }
public ActionResult Create([Bind(Include = "UserId,UserName")] Users users) { if (ModelState.IsValid) { db.Users.Add(users); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(users)); }
public void Create(Feedback entity) { using (FeedbackDbContext _context = new FeedbackDbContext()) { _context.Feedbacks.Add(FeedbackMapper.MapFeedbackEntityToFeedbackPersistence(entity)); _context.SaveChanges(); //ako ne sacuvamo nece se update-ovati baza } }
public void Update(Feedback entity) { using (FeedbackDbContext _context = new FeedbackDbContext()) { //Entity Framework ce po id-ju naci feedback i azurirati ga _context.Update(FeedbackMapper.MapFeedbackEntityToFeedbackPersistence(entity)); _context.SaveChanges(); //moramo sacuvati promene } }
//Creates a new user. There is no way to call this method from the API/UI public User Create(string id, string password) { var user = new User() { UserId = id }; user.PasswordHash = _passwordHasher.HashPassword(user, password); _context.Users.Add(user); _context.SaveChanges(); return(user); }
public bool Delete(Guid id) { using (FeedbackDbContext _context = new FeedbackDbContext()) { FeedbackPersistence feedback = _context.Feedbacks.Find(id); if (feedback == null) { return(false); //u principu vracamo true ili false, kao indikator uspesnosti operacije, ako ne pronadjemo id, operacija nije uspesna } _context.Feedbacks.Remove(feedback); _context.SaveChanges(); // cuvamo promene return(true); } }
public void Create(Feedback fb) { _context.Feedbacks.Add(fb); _context.SaveChanges(); }
public void CreateReview(Review review) { _context.Reviews.Add(review); _context.SaveChanges(); }