Ejemplo n.º 1
0
 public void AddEditVoucher(CustomerGiftVoucherDTO request, int userId, int branchId)
 {
     if (!string.IsNullOrWhiteSpace(request.GvinvoiceNo))
     {
         EditVoucher(request, userId, branchId);
     }
     else
     {
         AddVoucher(request, userId, branchId);
     }
 }
Ejemplo n.º 2
0
 public ActionResult AddEditVoucher([FromBody] CustomerGiftVoucherDTO request)
 {
     try
     {
         _customerGiftVoucherService.AddEditVoucher(request, UserId, BranchId);
         return(Ok(HttpStatusCode.Created));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Ejemplo n.º 3
0
        private void AddVoucher(CustomerGiftVoucherDTO voucher, int userId, int branchId)
        {
            voucher.GvinvoiceNo = String.Format("V{0:d9}", (DateTime.Now.Ticks / 10) % 1000000000);
            voucher.EnteredDate = DateTime.Now;
            voucher.EnteredBy   = userId;
            voucher.InvDateTime = DateTime.Now;
            voucher.BranchId    = branchId;
            voucher.IsRedeem    = false;
            voucher.IsCanceled  = false;

            _customerGiftVoucherRepository.Add(DomainDTOMapper.ToCustomerGiftVoucherDomain(voucher));
            _customerGiftVoucherRepository.SaveChanges();
        }
Ejemplo n.º 4
0
        private void EditVoucher(CustomerGiftVoucherDTO request, int userId, int branchId)
        {
            var voucher = _customerGiftVoucherRepository.FirstOrDefault(x => x.GvinvoiceNo == request.GvinvoiceNo);

            if (voucher != null)
            {
                voucher.BranchId   = branchId;
                voucher.CustomerId = request.CustomerId;
                //voucher.DepartmentId = request.DepartmentId;
                voucher.DueAmount = request.DueAmount;
                //voucher.InvDateTime = request.InvDateTime;
                voucher.ModifiedBy   = userId;
                voucher.ModifiedDate = DateTime.Now;
            }

            _customerGiftVoucherRepository.SaveChanges();
        }
Ejemplo n.º 5
0
 public static CustomerGiftVoucher ToCustomerGiftVoucherDomain(CustomerGiftVoucherDTO voucher)
 {
     return(AutoMapper.Mapper.Map <CustomerGiftVoucherDTO, CustomerGiftVoucher>(voucher));
 }