public DebitCategoryDTO updateDebitCategory(DebitCategoryDTO debitCategory) { var selectedDebitCategory = uow.GetRepository <DebitCategory>().Get(z => z.Id == debitCategory.Id); selectedDebitCategory = MapperFactory.CurrentMapper.Map(debitCategory, selectedDebitCategory); uow.GetRepository <DebitCategory>().Update(selectedDebitCategory); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <DebitCategoryDTO>(selectedDebitCategory)); }
public HttpResponseMessage Get(int Id) { DebitCategoryDTO selectedTitle = service.getDebitCategory(Id); if (selectedTitle == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title)); } return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle)); }
public HttpResponseMessage Put(DebitCategoryDTO DebitCategoryDTO) { DebitCategoryDTO dto = service.updateDebitCategory(DebitCategoryDTO); if (dto != null) { return(Request.CreateResponse(HttpStatusCode.OK, dto)); } else { return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title)); } }
public DebitCategoryDTO newDebitCategory(DebitCategoryDTO debitCategory) { if (!uow.GetRepository <DebitCategory>().GetAll().Any(z => z.Id == debitCategory.Id)) { var adedDebitCategory = MapperFactory.CurrentMapper.Map <DebitCategory>(debitCategory); adedDebitCategory = uow.GetRepository <DebitCategory>().Add(adedDebitCategory); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <DebitCategoryDTO>(adedDebitCategory)); } else { return(null); } }
public HttpResponseMessage Post(DebitCategoryDTO DebitCategoryDTO) { DebitCategoryDTO dto = service.newDebitCategory(DebitCategoryDTO); 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)); } }