示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
        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));
            }
        }
示例#4
0
 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);
     }
 }
示例#5
0
        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));
            }
        }