コード例 #1
0
 public ActionResult Create(EstadoClienteViewModels model)
 {
     if (ModelState.IsValid)
     {
         EstadoCliente.NombreEstado = model.NombreEstado;
         dbCtx.EstadoCliente.Add(EstadoCliente);
         dbCtx.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
        public ActionResult Edit(EstadoClienteViewModels model)
        {
            if (ModelState.IsValid)
            {
                EstadoCliente = dbCtx.EstadoCliente.FirstOrDefault(a => a.Id == model.Id);
                EstadoCliente.NombreEstado = model.NombreEstado;
                dbCtx.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult Edit(int id)
        {
            ViewBag.Title = "Editar Estado";

            EstadoClienteViewModels estado = new EstadoClienteViewModels();

            EstadoCliente       = dbCtx.EstadoCliente.FirstOrDefault(a => a.Id == id);
            estado.Id           = EstadoCliente.Id;
            estado.NombreEstado = EstadoCliente.NombreEstado;

            return(View(estado));
        }
コード例 #4
0
        public ActionResult Delete(EstadoClienteViewModels model)
        {
            var estado = (from p in dbCtx.EstadoCliente where p.Id == model.Id
                          select p).FirstOrDefault();

            dbCtx.EstadoCliente.Remove(estado);

            int num = dbCtx.SaveChanges();

            if (num > 0)
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK));
            }

            return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
        }