public IActionResult Post([FromBody] FormaPgto formaPgto) { formaPgto.Ativo = true; _db.FormaPgto.Add(formaPgto); _db.SaveChanges(); return(Ok(formaPgto)); }
public ActionResult Edit(FormaPgto data, bool continueAdd, bool isDelete) { if (!isDelete) { if (ModelState.IsValid) { db.Entry(data).State = EntityState.Modified; db.SaveChanges(); return(continueAdd ? RedirectToAction("Edit", new { id = data.formapgtoid }) : RedirectToAction("List")); } return(View(data)); } else { try { FormaPgto dataDelete = db.FormaPgto.Find(data.formapgtoid); db.FormaPgto.Remove(dataDelete); db.SaveChanges(); RedirectToAction("List"); } catch (DbEntityValidationException e) { //foreach (var result in e.EntityValidationErrors) // { // foreach (var error in result.ValidationErrors) // { ModelState.AddModelError("", e.Message); //} // } return(RedirectToAction("Edit", new { id = data.formapgtoid })); } return(RedirectToAction("List")); } }
// // GET: /TipoLead/Edit/5 public ActionResult Edit(int id) { FormaPgto data = db.FormaPgto.Find(id); if (data == null) { return(InvokeHttpNotFound()); } return(View(data)); }
public void FormaPgtoIncluir() { // Arrange var forma = new FormaPgto { AlteradoPor = 1, Descricao = "DINHEIRO" }; // Act var id = service.Gravar(forma); // Assert Assert.AreNotEqual(0, id); }
public ActionResult Create(FormaPgto data, bool continueAdd, FormCollection form) { ModelState.Clear(); data.formapgtoid = db.Database.SqlQuery <Int32>("select FormaPgto_Seq.NextVal from dual ").FirstOrDefault <Int32>(); TryValidateModel(data); if (ModelState.IsValid) { db.FormaPgto.Add(data); db.SaveChanges(); return(continueAdd ? RedirectToAction("Create") : RedirectToAction("List")); } return(View(data)); }
// GET public IActionResult CreateOrEdit(int?id) { var formaPgtoViewModel = new FormaPgtoViewModel(); if (id > 0) { FormaPgto formaPgto = _context.FormasPgtos.SingleOrDefault(m => m.FormaPgtoId == id); // AUTO MAPPER formaPgtoViewModel = Mapper.Map <FormaPgtoViewModel>(formaPgto); } return(View(formaPgtoViewModel)); }
public ActionResult Edit([Bind(Include = "Id,Descricao,Ativo")] FormaPgto forma) { try { forma.AlteradoPor = _login.GetIdUsuario(System.Web.HttpContext.Current.User.Identity.Name); forma.AlteradoEm = DateTime.Now; TryUpdateModel(forma); _service.Gravar(forma); return(RedirectToAction("Index")); } catch (ArgumentException e) { ModelState.AddModelError(string.Empty, e.Message); return(View(forma)); } }
public IActionResult Put([FromBody] FormaPgto formaPgto) { _db.Entry(formaPgto).State = EntityState.Modified; _db.SaveChanges(); return(Ok(formaPgto)); }