public void Adduser(User user) { using (_db) { _db.Entry(user.Role).State = EntityState.Unchanged; _db.Entry(user.CityId).State = EntityState.Unchanged; _db.Users.Add(user); _db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "ID,Name,Email,Password,ConfirmPassword,Gender,DateOfBirth,Address,PhoneNumber,UserTypeID")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public void AddProduct(Product product) { using (db) { db.Entry(product.Category).State = EntityState.Unchanged; db.Entry(product.User).State = EntityState.Unchanged; db.Products.Add(product); db.SaveChanges(); } }
public void AddCamera(Camera camera) { using (db) { db.Entry(camera.Brand).State = EntityState.Unchanged; db.Entry(camera.Series).State = EntityState.Unchanged; db.Entry(camera.Category).State = EntityState.Unchanged; db.Entry(camera.SubCategory).State = EntityState.Unchanged; db.Cameras.Add(camera); db.SaveChanges(); } }
public void UpdateBanner(MainBanner banner) { using (_db) { _db.Entry(banner).State = EntityState.Modified; _db.SaveChanges(); } }
public void AddMessage(Messages msg) { using (_db) { _db.Entry(msg.Converstion).State = EntityState.Unchanged; _db.Messages.Add(msg); _db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "ID,Name")] Subject subject) { if (ModelState.IsValid) { db.Entry(subject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subject)); }
public ActionResult Edit([Bind(Include = "ID,userID,Text")] Question question) { if (ModelState.IsValid) { db.Entry(question).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(question)); }
public void AddCity(City city) { DBContextClass db = new DBContextClass(); using (db) { db.Entry(city.Country).State = EntityState.Unchanged; db.Cities.Add(city); db.SaveChanges(); } }
public void DeleteCountry(Country country) { DBContextClass db = new DBContextClass(); using (db) { db.Entry(country).State = EntityState.Deleted; db.Countries.Remove(country); db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "ID,Text,Score,RightAnswer,QuestionID")] Answer answer) { if (ModelState.IsValid) { db.Entry(answer).State = EntityState.Modified; db.SaveChanges(); // return RedirectToAction("Index"); return(RedirectToAction("Details", "Questions", new { id = answer.QuestionID })); } return(View(answer)); }
public async Task <IActionResult> PutNotes(int id, Notes notes) { notes.id = id; _context.Entry(notes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NotesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }