// GET: Cliente public JsonResult AddCliente(ClienteDTO cliente) { var response = new Response <Clientes>(); try { Clientes cli = new Clientes(); cli.Cedula = cliente.Cedula; cli.Nombre = cliente.Nombre; cli.Email = cliente.Email; cli.Telefono = cliente.Telefono; cli.Provincia = cliente.Provincia; cli.Municipio = cliente.Municipio; cli.RNC = cliente.RNC; cli.RazonSocial = cliente.RazonSocial; cli.Posicion = cliente.Posicion; cli.Comentarios = cliente.Comentarios; dbc.Entry(cli).State = System.Data.Entity.EntityState.Added; dbc.SaveChanges(); if (cliente.file != null) { foreach (var file in cliente.file) { MemoryStream target = new MemoryStream(); file.InputStream.CopyTo(target); byte[] data = target.ToArray(); AdjuntoCliente adjunto = new AdjuntoCliente(); adjunto.Clientes = cli; adjunto.Adjunto = data; dbc.Entry(adjunto).State = System.Data.Entity.EntityState.Added; dbc.SaveChanges(); } } response.Success = true; } catch (Exception e) { var response2 = new Response <Exception>(); response2.Success = false; response2.Data = e; return(Json(e, JsonRequestBehavior.AllowGet)); } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "ID_Estado,Estado")] Estados estados) { if (ModelState.IsValid) { db.Entry(estados).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(estados)); }
public ActionResult Edit([Bind(Include = "Nombre,Apellido,Cedula")] Cliente cliente) { if (ModelState.IsValid) { db.Entry(cliente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cliente)); }
public ActionResult Edit([Bind(Include = "ID_Empleado,Nombre,Apellido,Telefono,Correo,ID_Estado")] Empleados empleados) { if (ModelState.IsValid) { db.Entry(empleados).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_Estado = new SelectList(db.Estados, "ID_Estado", "Estado", empleados.ID_Estado); return(View(empleados)); }
public ActionResult Edit([Bind(Include = "Numero_cuenta,Cedula,Fecha_apertura,Monto")] CuentaBancaria cuentaBancaria) { if (ModelState.IsValid) { db.Entry(cuentaBancaria).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Cedula = new SelectList(db.Cliente, "Cedula", "Nombre", cuentaBancaria.Cedula); return(View(cuentaBancaria)); }
public Reply Delete([FromBody] TareaViewModel modelo) { Reply oR = new Reply(); oR.result = 0; if (!Verify(modelo.token)) { oR.message = " No autorizado"; return(oR); } //validaciones if (!Validate(modelo)) { oR.message = error; return(oR); } try { using (PruebaEntities db = new PruebaEntities()) { Tarea oTarea = db.Tarea.Find(modelo.Id); oTarea.estado = modelo.estado; oTarea.Nombre = modelo.nombre; oTarea.descripcion = modelo.descripcion; db.Entry(oTarea).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); List <ListTareasViewModel> lst = (from d in db.Tarea select new ListTareasViewModel { nombre = d.Nombre, descripcion = d.descripcion }).ToList(); oR.result = 1; oR.data = lst; } } catch (Exception ex) { oR.message = "Ocurrio el siguiente error:" + ex.ToString(); throw; } return(oR); }
public ActionResult Editar(CrudViewModel model) { if (ModelState.IsValid) { using (PruebaEntities db = new PruebaEntities()) { var oCrud = db.crud.Find(model.Id); oCrud.Id = model.Id; oCrud.Nombre = model.Nombre; oCrud.Correo = model.Correo; oCrud.Fecha_nacimiento = model.Fecha_Nacimiento; db.Entry(oCrud).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Redirect("~/Crud/")); } return(View(model)); }
public Reply Login([FromBody] AccessViewModel model) { Reply oR = new Reply(); oR.result = 0; try { using (PruebaEntities db = new PruebaEntities()) { var lst = db.Usuario.Where(d => d.username == model.username && d.password == model.password); if (lst.Count() > 0) { oR.result = 1; oR.data = Guid.NewGuid().ToString(); Usuario oUser = lst.First(); oUser.token = (string)oR.data; db.Entry(oUser).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { oR.message = "Credenciales Erroneas"; } } } catch (Exception ex) { oR.result = 0; oR.message = " Ocurrió un error!"; } return(oR); }