public IHttpActionResult PutLoginDetail(int id, LoginDetail loginDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != loginDetail.loginid) { return(BadRequest()); } db.Entry(loginDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LoginDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "idotorgante,nombres,apellidos,redsocial,telefono,correo,fechanacimiento,lugarnacimiento,Id_Municipio,Id_Departamento")] tblOtorgante tblOtorgante) { if (ModelState.IsValid) { db.tblOtorgante.Add(tblOtorgante); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Otorgantes"; notificacion.Message = string.Format("Registro un nuevo Otorgante"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } ViewBag.Id_Departamento = new SelectList(db.tblDepartamentos, "Id_Departamento", "Departamento"); ViewBag.Id_Municipio = new SelectList(db.tblMunicipios, "id_Municipio", "Municipio"); return(View(tblOtorgante)); }
public IHttpActionResult PutUsuario(int id, Usuario usuario) { if (id != usuario.Id) { return(BadRequest()); } db.Entry(usuario).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UsuarioExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutDESIGNATION(int id, DESIGNATION dESIGNATION) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} if (id != dESIGNATION.DG_ID) { return(BadRequest()); } db.Entry(dESIGNATION).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DESIGNATIONExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "Id_Caso,Id_Cliente,Id_Categoria,Id_EstadoCaso,Id_Departamento,Id_Municipio,Id_Juzgado,Titulo,Numero_Caso,Fecha_Inicio,Fecha_Audiencia,Fecha_Agregado")] tblCasos tblCasos) { if (ModelState.IsValid) { ViewData["Fecha_Agregado"] = DateTime.Now.ToString(); db.tblCasos.Add(tblCasos); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Casos"; notificacion.Message = string.Format("Registro un nuevo caso"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } ViewBag.Id_Categoria = new SelectList(db.tblCategorias, "Id_Categoria", "Nombre_Categoria", tblCasos.Id_Categoria); ViewBag.Id_Cliente = new SelectList(db.tblClientes, "Id_Cliente", "NombreCompleto", tblCasos.Id_Cliente); ViewBag.Id_Departamento = new SelectList(db.tblDepartamentos, "Id_Departamento", "Departamento", tblCasos.Id_Departamento); ViewBag.Id_EstadoCaso = new SelectList(db.tblEstadosCasos, "Id_EstadoCaso", "Nombre_Estado", tblCasos.Id_EstadoCaso); ViewBag.Id_Juzgado = new SelectList(db.tblJuzgados, "Id_Juzgado", "Juzgado", tblCasos.Id_Juzgado); ViewBag.Id_Municipio = new SelectList(db.tblMunicipios, "id_Municipio", "Municipio", tblCasos.Id_Municipio); return(View(tblCasos)); }
public ActionResult Create(tblOtorgante otorgantes) { db.tblOtorgante.Add(otorgantes); db.SaveChanges(); return(RedirectToAction("index")); }
public ActionResult Create([Bind(Include = "Id_EstadoRegistro,Estado")] tblEstadosRegistros tblEstadosRegistros) { if (ModelState.IsValid) { db.tblEstadosRegistros.Add(tblEstadosRegistros); db.SaveChanges(); /*Notificacion*/ ApplicationDbContext bd = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Estado de registro Cliente/Personal"; notificacion.Message = string.Format("Registro un nuevo estado"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); bd.Notification.Add(notificacion); bd.SaveChanges(); /*Fin Notificacion*/ return(RedirectToAction("Index")); } return(View(tblEstadosRegistros)); }
public ActionResult Create(tblAfavorde af) { if (ModelState.IsValid) { db.tblAfavorde.Add(af); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "A favor de"; notificacion.Message = string.Format("Registro un nuevo A/F"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } ViewBag.Id_Departamento = new SelectList(db.tblDepartamentos, "Id_Departamento", "Departamento"); ViewBag.Id_Municipio = new SelectList(db.tblMunicipios, "id_Municipio", "Municipio"); return(View()); }
public ActionResult registration(Customer customer, HttpPostedFileBase imageFile = null) { string fileCustomerName = Path.GetFileNameWithoutExtension(imageFile.FileName); string extension = Path.GetExtension(imageFile.FileName); fileCustomerName = fileCustomerName + DateTime.Now.ToString("yymmssfff") + extension; customer.customerImage = "../../images/customerImage/" + fileCustomerName; fileCustomerName = Path.Combine(Server.MapPath("~/images/customerImage/"), fileCustomerName); imageFile.SaveAs(fileCustomerName); if (db.Customers.Any(p => p.customerUserName == customer.customerUserName)) { Response.Output.Write("<script>alert('user already exist')</script>"); return(View("", customer)); } customer.customerActive = true; db.Customers.Add(customer); db.SaveChanges(); Response.Output.Write("<script>alert('registration successfully')</script>"); return(View("Index")); }
public IHttpActionResult PutinfoMaster(int id, infoMaster infoMaster) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != infoMaster.Id) { return(BadRequest()); } db.Entry(infoMaster).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!infoMasterExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "Id_Historial,Id_Caso,Fecha_Inicio,Fecha_Final,Descripcion,Archivo,Fecha_Agregado")] tblHistorial tblHistorial) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; if (file.ContentLength > 0) { var img = (file.FileName).ToLower(); tblHistorial.Archivo = "/Content/Historial/" + img; file.SaveAs(Server.MapPath("~/Content/Historial/") + img); } db.tblHistorial.Add(tblHistorial); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Historial"; notificacion.Message = string.Format("Registro un nuevo historial"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } } ViewBag.Id_Caso = new SelectList(db.tblCasos, "Id_Caso", "Numero_Caso", tblHistorial.Id_Caso); return(View(tblHistorial)); }
public ActionResult Create([Bind(Include = "id_CategoriaPersonal,CategoriaPersonal")] tblCategoriaPersonal tblCategoriaPersonal) { if (ModelState.IsValid) { db.tblCategoriaPersonal.Add(tblCategoriaPersonal); db.SaveChanges(); /*Notificacion*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Categoria personal"; notificacion.Message = string.Format("Registro una nueva categoria"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*Fin Notificacion*/ return(RedirectToAction("Index")); } return(View(tblCategoriaPersonal)); }
public ActionResult Create([Bind(Include = "idEditable,fecha,entidad,instrumento,documento,tipo_documento,img,descripcion")] tblEditables tblEditables) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; if (file.ContentLength > 0) { var img = (file.FileName).ToLower(); tblEditables.img = "/Content/Editables/" + img; file.SaveAs(Server.MapPath("~/Content/Editables/") + img); } db.tblEditables.Add(tblEditables); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Editables"; notificacion.Message = string.Format("Registro un nuevo archivo editable"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } } return(View(tblEditables)); }
public IHttpActionResult PutEmpolyee(int id, Empolyee empolyee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != empolyee.EmployeeId) { return(BadRequest()); } db.Entry(empolyee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmpolyeeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "Id_Personal,Nombres,Apellidos,redsocial,Telefono,Correo,Direccion,Fecha_Nacimiento,id_CategoriaPersonal,Id_EstadoRegistro,Fecha_Agregado")] tblPersonal tblPersonal) { if (ModelState.IsValid) { ViewData["Fecha_Agregado"] = DateTime.Now.ToString("yyyy-MM-dd"); db.tblPersonal.Add(tblPersonal); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Personal"; notificacion.Message = string.Format("Registro un nuevo personal"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } ViewBag.id_CategoriaPersonal = new SelectList(db.tblCategoriaPersonal, "id_CategoriaPersonal", "CategoriaPersonal", tblPersonal.id_CategoriaPersonal); ViewBag.Id_EstadoRegistro = new SelectList(db.tblEstadosRegistros, "Id_EstadoRegistro", "Estado", tblPersonal.Id_EstadoRegistro); return(View(tblPersonal)); }
public ActionResult Create([Bind(Include = "Id_Categoria,Nombre_Categoria")] tblCategorias tblCategorias) { if (ModelState.IsValid) { db.tblCategorias.Add(tblCategorias); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblCategorias)); }
public ActionResult Create([Bind(Include = "Id_Departamento,Departamento")] tblDepartamentos tblDepartamentos) { if (ModelState.IsValid) { db.tblDepartamentos.Add(tblDepartamentos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblDepartamentos)); }
public ActionResult Create([Bind(Include = "Id_EstadoCaso,Nombre_Estado")] tblEstadosCasos tblEstadosCasos) { if (ModelState.IsValid) { db.tblEstadosCasos.Add(tblEstadosCasos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblEstadosCasos)); }
public ActionResult Create([Bind(Include = "id_Municipio,Municipio,Id_Departamento")] tblMunicipios tblMunicipios) { if (ModelState.IsValid) { db.tblMunicipios.Add(tblMunicipios); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id_Departamento = new SelectList(db.tblDepartamentos, "Id_Departamento", "Departamento", tblMunicipios.Id_Departamento); return(View(tblMunicipios)); }
/// <summary> /// Adds or edits the <paramref name="Acceptor"/> to the db. /// </summary> /// <param name="Acceptor">The donate.</param> /// <returns>ID of added of edited acceptor.</returns> public int CreateAcceptor(Acceptor Acceptor) { if ((Acceptor.User.Id == 0) && (context.Users.FirstOrDefault(x => x.Login == Acceptor.User.Login) != default(User))) { return(0); } context.Entry(Acceptor).State = Acceptor.Id == 0 ? EntityState.Added : EntityState.Modified; context.SaveChanges(); return(Acceptor.Id); }
public ActionResult Create([Bind(Include = "idlibros,fecha,correlativo,instrumento,folios,libro,img,word,idotorgante,idfavorde,id_Personal")] tblLibros tblLibros) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; HttpPostedFileBase file2 = Request.Files[1]; if (file.ContentLength > 0) { var img = (file.FileName).ToLower(); tblLibros.img = "/Content/Libros/" + img; file.SaveAs(Server.MapPath("~/Content/Libros/") + img); } if (file2.ContentLength > 0) { var doc = (file2.FileName).ToLower(); tblLibros.word = "/Content/Libros/" + doc; file2.SaveAs(Server.MapPath("~/Content/Libros/") + doc); } db.tblLibros.Add(tblLibros); db.SaveChanges(); /*NOTIFICACION*/ ApplicationDbContext dbs = new ApplicationDbContext(); Notifications notificacion = new Notifications(); notificacion.Module = "Libros"; notificacion.Message = string.Format("Registro un nuevo libro"); notificacion.Date = DateTime.Now; notificacion.Viewed = false; notificacion.Usuario_Id = User.Identity.GetUserId(); dbs.Notification.Add(notificacion); dbs.SaveChanges(); /*FIN NOTIFICACION*/ return(RedirectToAction("Index")); } } ViewBag.idfavorde = new SelectList(db.tblAfavorde, "idfavorde", "nombres", tblLibros.idfavorde); ViewBag.idotorgante = new SelectList(db.tblOtorgante, "idotorgante", "nombres", tblLibros.idotorgante); ViewBag.id_Personal = new SelectList(db.tblPersonal, "Id_Personal", "Nombres", tblLibros.id_Personal); return(View(tblLibros)); }
public ActionResult Create([Bind(Include = "Id_Juzgado,Juzgado,telefono,correo,direccion,Id_Departamento,Id_Municipio")] tblJuzgados tblJuzgados) { if (ModelState.IsValid) { db.tblJuzgados.Add(tblJuzgados); db.SaveChanges(); return(RedirectToAction("Index")); } List <tblDepartamentos> DepartamentosList = db.tblDepartamentos.ToList(); ViewBag.DepartamentosList = new SelectList(DepartamentosList, "Id_Departamento", "Departamento", tblJuzgados.Id_Departamento); //ViewBag.tblDepartamentos = new SelectList(db.tblDepartamentos, "Id_Departamento", "Departamento", tblJuzgados.Id_Departamento); ViewBag.Id_Municipio = new SelectList(db.tblMunicipios, "id_Municipio", "Municipio", tblJuzgados.Id_Municipio); return(View(tblJuzgados)); }
public ActionResult Create(tblLibros libros) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; if (file.ContentLength > 0) { var img = (file.FileName).ToLower(); libros.img = "/Content/Libros/" + img; file.SaveAs(Server.MapPath("~/Content/Libros/") + img); } db.tblLibros.Add(libros); db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(libros)); }
public IHttpActionResult PostInfos(infoMaster info) { try { db.infoMasters.Add(info); db.SaveChanges(); return(Ok("Your data is inserted!")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
/// <summary> /// Adds <paramref name="Donor"/> to the db. /// </summary> /// <param name="Donor">The donate.</param> /// <returns>Id of added donor</returns> public string CreateDonor(Donor Donor) { if (!context.Donors.Any(x => x.PESEL == Donor.PESEL)) { context.Entry(Donor).State = EntityState.Added; context.SaveChanges(); return(Donor.PESEL); } else { return(""); } }
public ActionResult Create(Table_1 table_1) { try { using (dbModel DbModel = new dbModel()) { DbModel.Table_1.Add(table_1); DbModel.SaveChanges(); } // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int ID, FormCollection collection) { try { // TODO: Add delete logic here using (dbModel Dbmodel = new dbModel()) { Table_1 table_1 = Dbmodel.Table_1.Where(x => x.id == ID).FirstOrDefault(); Dbmodel.Table_1.Remove(table_1); Dbmodel.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, Table_1 table_1) { try { using (dbModel Dbmodel = new dbModel()) { Dbmodel.Entry(table_1).State = EntityState.Modified; Dbmodel.SaveChanges(); } // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
/// <summary> /// Adds <paramref name="Donate"/> th the db and makes changes to the statistics. /// </summary> /// <param name="Donate">The donate.</param> /// <returns>Id of added donate</returns> public int CreateDonate(Donate Donate) { context.Donates.Add(Donate); BloodTypeMarker BloodTypeMarker; switch (Donate.Donor.Blood_Type) { case BloodType.O: BloodTypeMarker = BloodTypeMarker.O; break; case BloodType.A: BloodTypeMarker = BloodTypeMarker.A; break; case BloodType.B: BloodTypeMarker = BloodTypeMarker.B; break; default: BloodTypeMarker = BloodTypeMarker.AB; break; } if (Donate.Donor.Blood_RhMarker) { BloodTypeMarker += 1; } var stat = context.Statistics.Find(BloodTypeMarker); stat.TotalAmount += Donate.Amount; context.Entry(stat).State = EntityState.Modified; context.SaveChanges(); return(Donate.Id); }
public ActionResult Create(tblAfavorde afavorde) { db.tblAfavorde.Add(afavorde); db.SaveChanges(); return(RedirectToAction("Index")); }