Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
            }
        }
Esempio n. 4
0
 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);
     }
 }
Esempio n. 5
0
        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));
            }
        }
Esempio n. 6
0
        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"));
 }