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)); } }
// 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 ActionResult DeleteConfirmed(int id) { SalaryTabulator salaryTabulator = salaryTabuladorService.Get(x => x.Id == id && x.Active == true); if (salaryTabulator == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } salaryTabuladorService.Delete(salaryTabulator); return(RedirectToAction("Index")); }
public void Update(SalaryTabulator entity) { this.repository.Update(entity); }
public void Insert(SalaryTabulator entity) { this.repository.Insert(entity); }
public void Delete(SalaryTabulator entity) { entity.Active = false; this.repository.Update(entity); }