コード例 #1
0
 public IActionResult Post([FromBody] FormaPgto formaPgto)
 {
     formaPgto.Ativo = true;
     _db.FormaPgto.Add(formaPgto);
     _db.SaveChanges();
     return(Ok(formaPgto));
 }
コード例 #2
0
ファイル: FormaPgtoController.cs プロジェクト: shpsyte/CRMFx
 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"));
     }
 }
コード例 #3
0
ファイル: FormaPgtoController.cs プロジェクト: shpsyte/CRMFx
        //
        // GET: /TipoLead/Edit/5
        public ActionResult Edit(int id)
        {
            FormaPgto data = db.FormaPgto.Find(id);

            if (data == null)
            {
                return(InvokeHttpNotFound());
            }
            return(View(data));
        }
コード例 #4
0
        public void FormaPgtoIncluir()
        {
            // Arrange
            var forma = new FormaPgto {
                AlteradoPor = 1, Descricao = "DINHEIRO"
            };

            // Act
            var id = service.Gravar(forma);

            // Assert
            Assert.AreNotEqual(0, id);
        }
コード例 #5
0
ファイル: FormaPgtoController.cs プロジェクト: shpsyte/CRMFx
        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));
        }
コード例 #6
0
        // 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));
        }
コード例 #7
0
        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));
            }
        }
コード例 #8
0
 public IActionResult Put([FromBody] FormaPgto formaPgto)
 {
     _db.Entry(formaPgto).State = EntityState.Modified;
     _db.SaveChanges();
     return(Ok(formaPgto));
 }