public ActionResult Delete(bool active, int?id) { if (id == null) { sb.Clear(); sb.Append("It needes a Id to delete a Salary tabulator"); SeriLogHelper.WriteError(null, sb.ToString()); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { SalaryTabulator salaryTabulator = salaryTabuladorService.Get(x => x.Id == id && x.Active == !active); if (salaryTabulator == null) { return(HttpNotFound()); } salaryTabulator.Active = active; salaryTabuladorService.Update(salaryTabulator); SalaryTabulatorDTO salaryTabulatorDTO = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulatorDTO>(salaryTabulator); return(Json(salaryTabulatorDTO, JsonRequestBehavior.DenyGet)); } catch (Exception e) { sb.Clear(); sb.Append(e.ToString()); return(new JsonHttpStatusResult(sb.ToString(), HttpStatusCode.InternalServerError)); } }
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)); }