/// <summary> /// 注册一个新的对象到仓储上下文中 /// </summary> /// <typeparam name="TEntity">实体类型</typeparam> /// <param name="entity">要注册的对象</param> public void RegisterNew <TEntity>(TEntity entity) where TEntity : Entity { if (_dbContext.Entry(entity).State == EntityState.Detached) { _dbContext.Entry(entity).State = EntityState.Added; } IsCommited = false; }
public async Task <IActionResult> PutBook(int id, Book book) { if (id != book.Id) { return(BadRequest()); } _context.Entry(book).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Person> Create(Person person) { _context.Entry(person).State = EntityState.Added; await _context.SaveChangesAsync(); return(person); }
public async Task <IActionResult> SaveChanges([FromRoute] int id, [FromBody] User modifiedUser) { if (id != modifiedUser.Id) { return(BadRequest()); } _db.Entry(modifiedUser).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPiResults([FromRoute] int id, [FromBody] PiResults piResults) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != piResults.Id) { return(BadRequest()); } _context.Entry(piResults).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PiResultsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutStore(int id, Store store) { if (id != store.Id) { return(BadRequest()); } _context.Entry(store).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreExists(id)) { return(NotFound()); } else { throw; } } return(Ok()); }
public async Task <IActionResult> PutFornecedor([FromRoute] short id, [FromBody] Fornecedor fornecedor) { _logger.LogInformation("FornecedorController - PutFornecedor - Method Call"); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != fornecedor.FornecedorID) { return(BadRequest()); } _context.Entry(fornecedor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FornecedorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutDemoModel(int id, DemoModel demoModel) { if (id != demoModel.Id) { return(BadRequest()); } _context.Entry(demoModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DemoModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUser(string id, User user) { if (id != user.Id) { return(BadRequest()); } _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(Ok()); }
public async Task <IActionResult> PutProcesso(int id, Processo processo) { if (id != processo.Id) { return(BadRequest()); } _context.Entry(processo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProcessoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEstadoFatura([FromRoute] short id, [FromBody] EstadoFatura estadoFatura) { _logger.LogInformation("EstadoFaturaController - PutEstadoFatura (with Id = " + id + ") - Method Call"); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != estadoFatura.EstadoFaturaID) { return(BadRequest()); } _context.Entry(estadoFatura).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EstadoFaturaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutWeatherForecast(int id, WeatherForecast weatherForecast) { if (id != weatherForecast.Id) { return(BadRequest()); } _context.Entry(weatherForecast).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WeatherForecastExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "CustomerId,Firstname,Middlename,LastName,DOB,email1,email2,phone,phone2,NationalIdNo,tole,homeno,State,Country,ZipCode,CreatedBy,CreatedDate,EditedBy,EditedDate")] Customer customer) { if (ModelState.IsValid) { customer.EditedBy = Session["userEmail"].ToString(); customer.EditedDate = DateTime.Now; try { customer.category = Session["ACategory"].ToString(); db.Entry(customer).State = EntityState.Modified; String Operation = "Customer edited Sucessfully"; db.ActivityLogs.Add(new ActivityLog { Operation = Operation, CreatedBy = Session["userEmail"].ToString(), CreatedDate = DateTime.Now, category = Session["ACategory"].ToString() }); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } return(View(customer)); }
public void Update(T Entity) { Entity.UpdatedDate = DateTime.Now; Entity.UpdatedBy = UserStateManagement.UserId; _dbSet.Attach(Entity); _dataContext.Entry(Entity).State = EntityState.Modified; }
public async Task<IActionResult> PutCliente(int id, Cliente cliente) { if (id != cliente.Id) { return BadRequest(); } _context.Entry(cliente).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(id)) { return NotFound(); } else { throw; } } return NoContent(); }
public void Do(T item) { using (var db = new DemoDbContext()) { db.Entry(item).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "ktdn")] Encrytion encrytion) { if (ModelState.IsValid) { db.Entry(encrytion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(encrytion)); }
public ActionResult Edit([Bind(Include = "NameHuman,PositionHuman,IDhuman,PhoneNumber")] Human human) { if (ModelState.IsValid) { db.Entry(human).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(human)); }
public ActionResult Edit([Bind(Include = "MaNV,HoNV,TenNV,ChucVu,SoCMT,DiaChi")] NhanVien nhanVien) { if (ModelState.IsValid) { db.Entry(nhanVien).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhanVien)); }
public ActionResult Edit([Bind(Include = "StudentID,StudentName,Age")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit([Bind(Include = "MaHD,TenHD,NgayTT,ThanhTien,MaKH")] HoaDon hoaDon) { if (ModelState.IsValid) { db.Entry(hoaDon).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hoaDon)); }
public ActionResult Edit([Bind(Include = "CCCD,NhanvienID,Vitri,FullName")] Nhanvien nhanvien) { if (ModelState.IsValid) { db.Entry(nhanvien).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhanvien)); }
public ActionResult Edit([Bind(Include = "TenKh,MaKh,HoKh,SoCMT,NgayDen,NgayDi,SoDT")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Edit([Bind(Include = "CCCD,FullName")] Person person) { if (ModelState.IsValid) { db.Entry(person).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(person)); }
public ActionResult Edit([Bind(Include = "UserName,Password")] Account account) { if (ModelState.IsValid) { db.Entry(account).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(account)); }
public ActionResult Edit([Bind(Include = "TenDDH,GiaTriDDH,TinhTrang")] DonDatHang donDatHang) { if (ModelState.IsValid) { db.Entry(donDatHang).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(donDatHang)); }
public ActionResult Edit([Bind(Include = "CCCD,Address,University,FullName")] Student1 student1) { if (ModelState.IsValid) { db.Entry(student1).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student1)); }
public ActionResult Edit([Bind(Include = "NameItem,IDIteam,PriceItem,AmountItem")] Item item) { if (ModelState.IsValid) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Edit([Bind(Include = "TenDV,MaDV,Gia")] DichVu dichVu) { if (ModelState.IsValid) { db.Entry(dichVu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dichVu)); }
public ActionResult Edit([Bind(Include = "IDPet,TenPet,LoaiPet,TuoiCuaPet")] ShopPet shopPet) { if (ModelState.IsValid) { db.Entry(shopPet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shopPet)); }