// GET: Employee/Edit/5 public ActionResult Edit(int?id) { if (id == null) { sb.Clear(); sb.Append("BadRequest: It needs the Id for edit a Employee details"); SeriLogHelper.WriteError(null, sb.ToString()); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var employee = _employeeService.Get(x => x.Id == id); if (employee == null) { sb.Clear(); sb.AppendFormat("Employee do not found with the id {0}", id); SeriLogHelper.WriteWarning(null, sb.ToString()); return(HttpNotFound()); } EmployeeDTO employeeDTO = AutoMapperConfiguration.Instance.Mapper.Map <EmployeeDTO>(employee); var departamentsDTO = AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <DepartamentDTO> >(_departamentService.GetAll()); var salaryTabulatorsDTO = AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <SalaryTabulatorDTO> >(_salaryTabulatorService.GetAll()); ViewBag.DepartamentId = new SelectList(departamentsDTO, "Id", "Name", employeeDTO.DepartamentId); ViewBag.SalaryTabulatorId = new SelectList(salaryTabulatorsDTO, "Id", "Key", employeeDTO.SalaryTabulatorId); return(View(employeeDTO)); }
// GET: SalaryTabulator/Edit/5 public ActionResult Edit(int?id) { if (id == null) { sb.Clear(); sb.Append("BadRequest: It needs the Id for edit a Salary Tabulator"); SeriLogHelper.WriteError(null, sb.ToString()); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SalaryTabulator salaryTabulator = salaryTabuladorService.Get(x => x.Id == id); if (salaryTabulator == null) { sb.Clear(); sb.AppendFormat("Salary tabulator do not found with the id {0}", id); SeriLogHelper.WriteWarning(null, sb.ToString()); return(HttpNotFound()); } var salaryTabulatorDTO = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulatorDTO>(salaryTabulator); var jobs = jobService.GetMany(x => x.Active == true); var jobsDTO = AutoMapperConfiguration.Instance.Mapper.Map <IEnumerable <JobDTO> >(jobs); ViewBag.JobId = new SelectList(jobsDTO, "Id", "Name", salaryTabulatorDTO.JobId); return(View(salaryTabulatorDTO)); }
public void TestSeriLog() { try { SeriLogHelper.WriteDebug(null, "Debug "); Debug.WriteLine("Debug"); SeriLogHelper.WriteWarning(null, "Warning "); throw new NotImplementedException(); } catch (Exception e) { SeriLogHelper.WriteError(e, "Error"); SeriLogHelper.WriteFatal(e, "Fatal"); SeriLogHelper.WriteVerbose(e, "Verbose"); throw; } }
//GET: Employee/Details/5 public ActionResult Details(int?id) { if (id == null) { sb.Clear(); sb.Append("BadRequest: It needs the Id for request the Employee "); SeriLogHelper.WriteError(null, sb.ToString()); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeDTO employeeDTO = AutoMapperConfiguration.Instance.Mapper.Map <EmployeeDTO>(_employeeService.GetByID(id)); if (employeeDTO == null) { sb.Clear(); sb.AppendFormat("Not found the employee with id {0}", id); SeriLogHelper.WriteWarning(null, sb.ToString()); return(HttpNotFound()); } return(View(employeeDTO)); }
// GET: SalaryTabulator/Details/5 public ActionResult Details(int?id) { if (id == null) { sb.Clear(); sb.Append("BadRequest: It needs the Id for request the SalaryTabulator details"); SeriLogHelper.WriteError(null, sb.ToString()); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var salaryTabulator = salaryTabuladorService.Get(x => x.Id == id); var salaryTabulatorDTO = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulatorDTO>(salaryTabulator); if (salaryTabulatorDTO == null) { sb.Clear(); sb.AppendFormat("Not found the salary tabulator with id {0}", id); SeriLogHelper.WriteWarning(null, sb.ToString()); return(HttpNotFound()); } return(View(salaryTabulatorDTO)); }
public JsonResult EditJson(SalaryTabulatorDTO salaryTabulatorDTO) { if ((int)salaryTabulatorDTO.TabulatorLevel == 0) { sb.Clear(); sb.Append("It needs a tabulator level to edit a salary tabulator"); SeriLogHelper.WriteWarning(null, sb.ToString()); var data = new ErrorByKey[1] { new ErrorByKey { key = "TabulatorLevel", errors = new string[1] { "Requerido" } } }; return(new JsonHttpStatusResult(data, HttpStatusCode.BadRequest)); } var salaryTabulator = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulator>(salaryTabulatorDTO); salaryTabuladorService.Update(salaryTabulator); return(Json(salaryTabulatorDTO, JsonRequestBehavior.DenyGet)); }
public JsonResult EditJson(EmployeeDTO employeeDTO) { if ((int)employeeDTO.Gender == 0) { sb.Clear(); sb.Append("It needs a gender to edit a employee"); SeriLogHelper.WriteWarning(null, sb.ToString()); var data = new ErrorByKey[1] { new ErrorByKey { key = "Gender", errors = new string[1] { "Requerido" } } }; return(new JsonHttpStatusResult(data, HttpStatusCode.BadRequest)); } var employee = AutoMapperConfiguration.Instance.Mapper.Map <Employee>(employeeDTO); _employeeService.Update(employee); return(Json(employeeDTO, JsonRequestBehavior.DenyGet)); }