public DebitDTO updateDebit(DebitDTO Debit) { var selectedDebit = uow.GetRepository <Debit>().Get(z => z.Id == Debit.Id); selectedDebit = MapperFactory.CurrentMapper.Map(Debit, selectedDebit); uow.GetRepository <Debit>().Update(selectedDebit); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <DebitDTO>(selectedDebit)); }
public HttpResponseMessage Get(int Id) { DebitDTO selectedDebit = service.getDebit(Id); if (selectedDebit == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title)); } return(Request.CreateResponse(HttpStatusCode.OK, selectedDebit)); }
public HttpResponseMessage Put(DebitDTO debitDTO) { DebitDTO dto = service.updateDebit(debitDTO); if (dto != null) { return(Request.CreateResponse(HttpStatusCode.OK, dto)); } else { return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title)); } }
public DebitDTO newDebit(DebitDTO Debit) { if (!uow.GetRepository <Debit>().GetAll().Any(z => z.Id == Debit.Id)) { var adedDebit = MapperFactory.CurrentMapper.Map <Debit>(Debit); adedDebit = uow.GetRepository <Debit>().Add(adedDebit); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <DebitDTO>(adedDebit)); } else { return(null); } }
public HttpResponseMessage Post(DebitDTO debitDTO) { DebitDTO dto = service.newDebit(debitDTO); if (dto != null) { HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, dto); message.Headers.Location = new Uri(Request.RequestUri + "/" + dto.Id); return(message); } else { return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.add_title)); } }
public DebitDTO newDebit(DebitDTO Debit) { var adedDebit = MapperFactory.CurrentMapper.Map <Debit>(Debit); uow.GetRepository <Debit>().Add(adedDebit); uow.SaveChanges(); var addedEmployeeDebit = new EmployeeDebit() { EmployeeId = Debit.EmployeeId, DebitId = adedDebit.Id }; uow.GetRepository <EmployeeDebit>().Add(addedEmployeeDebit); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <DebitDTO>(adedDebit)); }
public IActionResult ListDebit(DebitDTO debit) { service.getDebit(debit.EmployeeId); return(RedirectToAction("Index")); }
public IActionResult AddDebit(DebitDTO debit) { service.newDebit(debit); return(RedirectToAction("Index", "Home")); }