public ActionResult DeleteConfirmed(int id) { if (GetUsuario().cd_usuario != "ROOT") { return(RedirectToAction("Index", "Home")); } Consorcio consorcio = db.Consorcio.Find(id); db.Consorcio.Remove(consorcio); db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddConsorcio() { ConsorcioRepository repository = new ConsorcioRepository(); Consorcio consorcio = new Consorcio() { Nombre = "Primero" }; repository.Add(consorcio); var result = repository.GetList(); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual(consorcio.Nombre, result[0].Nombre); Assert.AreEqual(1, result[0].Id); }
public ActionResult Edit([Bind(Include = "cd_consorcio,tx_descripcion")] Consorcio consorcio) { if (GetUsuario().cd_usuario != "ROOT") { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { db.Entry(consorcio).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.cd_consorcio = new SelectList(db.Consorcio, "cd_consorcio", "cd_consorcio", consorcio.cd_consorcio); return(View(consorcio)); }
public bool AgregarEmpleado(string apellido, string pNombre, string cuil, double ValorHora, double horaMes, int idConsorcio, string nombre, string cuit) { var result = false; Consorcio oConsorcio = new Consorcio(nombre, cuit); oConsorcio.ConsorcioId = idConsorcio; Empleado oEmpleado = new Empleado(apellido, nombre, cuil, ValorHora, horaMes, oConsorcio); if (listaEmpleados.Buscar(cuil) == null) { listaEmpleados.agregarEmpleado(oEmpleado); result = true; } return(result); }
// GET: Consorcio/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Consorcio consorcio = db.Consorcio.Find(id); if (consorcio == null) { return(HttpNotFound()); } if (GetUsuario().cd_usuario != "ROOT") { return(RedirectToAction("Index", "Home")); } return(View(consorcio)); }
// GET: Consorcio/Edit/5 public ActionResult Edit(int?id) { if (GetUsuario().cd_usuario != "ROOT") { return(RedirectToAction("Index", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Consorcio consorcio = db.Consorcio.Find(id); if (consorcio == null) { return(HttpNotFound()); } ViewBag.cd_consorcio = new SelectList(db.Consorcio, "cd_consorcio", "cd_consorcio", consorcio.cd_consorcio); return(View(consorcio)); }
private void btnGuardar_Click(object sender, EventArgs e) { var result = false; var message = String.Empty; string apellido = txtApellido.Text; string nombre = txtNombre.Text; string cuil = txtCuil.Text; //Corregir Consorcio oConsorcio = (Consorcio)cmbNombre.SelectedItem; if (cmbNombre.SelectedIndex.Equals(0)) { if (!String.IsNullOrEmpty(txtApellido.Text) && !String.IsNullOrEmpty(txtNombre.Text) && !String.IsNullOrEmpty(txtCuil.Text) && !String.IsNullOrEmpty(txtValorHora.Text) && !String.IsNullOrEmpty(txtValorMes.Text)) { result = cEmpleado.AgregarEmpleado(apellido, nombre, cuil, Convert.ToDouble(txtValorHora.Text), Convert.ToDouble(txtValorMes.Text), oConsorcio.ConsorcioId, oConsorcio.Nombre, oConsorcio.Cuit); } else { message = "Debe llenar los campos vacios"; } } else { message = "Debe llenar los campos vacios"; } if (!result && String.IsNullOrEmpty(message)) { message = "Ya existe empleado"; } MessageBox.Show(message); txtNombre.Clear(); txtApellido.Clear(); txtApellido.Clear(); txtValorHora.Clear(); txtValorMes.Clear(); }