public bool add(HonorarioDTO Honorario) { using (var context = getContext()) { try { Honorario nuevo = new Honorario(); nuevo.Nombre = Honorario.Nombre; nuevo.Estado = true; nuevo.IdEmpresa = Honorario.IdEmpresa; context.Honorario.Add(nuevo); context.SaveChanges(); return true; } catch (Exception e) { throw e; } } }
public bool update(HonorarioDTO Honorario) { using (var context = getContext()) { try { var row = context.Honorario.Where(x => x.IdHonorario == Honorario.IdHonorario).SingleOrDefault(); row.Nombre = Honorario.Nombre; row.Estado = Honorario.Estado; row.IdEmpresa = Honorario.IdEmpresa; context.SaveChanges(); return true; } catch (Exception e) { throw e; } } }
public ActionResult AddHonorario(HonorarioDTO dto) { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } try { HonorarioBL objBL = new HonorarioBL(); if (dto.IdHonorario == 0) { if (objBL.add(dto)) { createResponseMessage(CONSTANTES.SUCCESS); return RedirectToAction("Honorarios"); } } else if (dto.IdHonorario != 0) { if (objBL.update(dto)) { createResponseMessage(CONSTANTES.SUCCESS); return RedirectToAction("Honorarios"); } else { createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE); } } else { createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE); } } catch (Exception e) { if (dto.IdHonorario != 0) createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE); else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE); } TempData["Honorario"] = dto; return RedirectToAction("Honorario"); }
public ActionResult Honorario(int? id = null) { if (!this.currentUser()) { return RedirectToAction("Ingresar"); } if (!this.isAdministrator()) { return RedirectToAction("Index"); } ViewBag.Title = "Forma de Pago"; MenuNavBarSelected(7); UsuarioDTO currentUser = getCurrentUser(); HonorarioBL objBL = new HonorarioBL(); var objSent = TempData["Honorario"]; if (objSent != null) { TempData["Honorario"] = null; return View(objSent); } HonorarioDTO obj; if (id != null) { obj = objBL.getHonorarioEnEmpresa((int)currentUser.IdEmpresa, (int)id); if (obj == null) return RedirectToAction("Honorarios"); if (obj.IdEmpresa != currentUser.IdEmpresa) return RedirectToAction("Honorarios"); return View(obj); } obj = new HonorarioDTO(); obj.IdEmpresa = currentUser.IdEmpresa; return View(obj); }