public ActionResult Edit(Models.User User) { Models.User user = db.Users.Find(User.Id); user.Senha = user.Senha; user.ConfirmarSenha = user.Senha; db.Entry(User).State = EntityState.Detached; AesCryptoServiceProvider aes = new AesCryptoServiceProvider(); aes.BlockSize = 128; aes.KeySize = 256; aes.IV = Encoding.UTF8.GetBytes(AesIV256BD); aes.Key = Encoding.UTF8.GetBytes(AesKey256BD); aes.Mode = CipherMode.CBC; aes.Padding = PaddingMode.PKCS7; byte[] src = Encoding.Unicode.GetBytes(user.Email); using (ICryptoTransform decrypt = aes.CreateEncryptor()) { byte[] dest = decrypt.TransformFinalBlock(src, 0, src.Length); user.Email = Convert.ToBase64String(dest); } db.Entry(User).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public async Task Delete(T entidad) { _context.Entry(entidad).State = EntityState.Deleted; _context.Set <T>().Remove(entidad); await _context.SaveChangesAsync(); }
public ActionResult Edit([Bind(Include = "User_ID,CTUSER_ID,User_Name,User_Detail,User_TK,User_MK")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CTUSER_ID = new SelectList(db.ChiTietUses, "CTUSER_ID", "CTUSER_ID", user.CTUSER_ID); return(View(user)); }
public async Task <IActionResult> PutClassRoom([FromRoute] int id, [FromBody] ClassRoom classRoom) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != classRoom.Id) { return(BadRequest()); } _context.Entry(classRoom).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassRoomExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutContacto(int id, Contacto contacto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != contacto.SivilaId) { return(BadRequest()); } db.Entry(contacto).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ContactoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutClassInfo(int id, ClassInfo classInfo) { if (id != classInfo.Id) { return(BadRequest()); } _context.Entry(classInfo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassInfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutProduct(int id, Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductID) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "Id,Nome,Cnpj,Email,Telefone")] Fornecedor fornecedor) { if (ModelState.IsValid) { db.Entry(fornecedor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fornecedor)); }
public ActionResult Edit([Bind(Include = "CTUSER_ID,CTUSER_LEVEL,CTUSER_TRANGTHAI")] ChiTietUs chiTietUs) { if (ModelState.IsValid) { db.Entry(chiTietUs).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chiTietUs)); }
public void Update(Author author) { try { _context.Entry <Author>(author).State = EntityState.Modified; _context.SaveChanges(); } catch { } }
public ActionResult Edit([Bind(Include = "Ruong_ID,User_ID,Ruong_Name,Ruong_DienTich,Ruong_MoTa")] Ruong ruong) { if (ModelState.IsValid) { db.Entry(ruong).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index/" + Session["User_ID"])); } ViewBag.User_ID = new SelectList(db.Users, "User_ID", "User_Name", ruong.User_ID); return(View(ruong)); }
public ActionResult Edit([Bind(Include = "CS_ID,Ruong_ID,CS_Name,CS_MoTa,CS_Mua")] ChamSoc chamSoc) { if (ModelState.IsValid) { db.Entry(chamSoc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index/" + Session["Ruong_ID"])); } ViewBag.Ruong_ID = new SelectList(db.Ruongs, "Ruong_ID", "Ruong_Name", chamSoc.Ruong_ID); return(View(chamSoc)); }
public ActionResult Edit([Bind(Include = "Id,Nome,Descricao,CorProduto,StatusProduto,IdFornecedor")] Produto produto) { if (ModelState.IsValid) { db.Entry(produto).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdFornecedor = new SelectList(db.Fornecedors, "Id", "Nome", produto.IdFornecedor); return(View(produto)); }
public ActionResult Edit([Bind(Include = "TH_ID,Ruong_ID,TH_Name,TH_ChiSo,TH_TienTrenDa,TH_TongTien,TH_MoTa")] ThuHoach thuHoach) { if (ModelState.IsValid) { db.Entry(thuHoach).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index/" + Session["Ruong_ID"])); } ViewBag.Ruong_ID = new SelectList(db.Ruongs, "Ruong_ID", "Ruong_Name", thuHoach.Ruong_ID); return(View(thuHoach)); }
public ActionResult Edit([Bind(Include = "CSCT_ID,CSCT_TenThuoc,CSCT_SoLuong,CSCT_Ngay,CS_ID,CSCT_TongTien")] ChamSocChiTiet chamSocChiTiet) { if (ModelState.IsValid) { db.Entry(chamSocChiTiet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index/" + Session["CS_ID"])); } ViewBag.CS_ID = new SelectList(db.ChamSocs, "CS_ID", "CS_Name", chamSocChiTiet.CS_ID); return(View(chamSocChiTiet)); }