private void CheckVoucherUsed(string VoucherCode)
        {
            IVoucherService voucherService = DependencyUtils.Resolve <IVoucherService>();

            if (!string.IsNullOrEmpty(VoucherCode))
            {
                var voucher = voucherService.GetVoucherIsNotUsedAndCode(VoucherCode);
                if (voucher.MembershipCardId == null)
                {
                    voucher.UsedQuantity++;
                    if (voucher.UsedQuantity >= voucher.Quantity)
                    {
                        voucher.isUsed = true;
                    }
                    var voucherVM = new VoucherAPIViewModel(voucher);
                    voucher = voucherVM.ToEntity();
                    voucherService.Update(voucher);
                }
                else
                {
                    voucher.isUsed = true;
                    var voucherVM = new VoucherAPIViewModel(voucher);
                    voucher = voucherVM.ToEntity();
                    voucherService.Update(voucher);
                }
            }
        }
Example #2
0
 public BasketController(IProductService productService, IMapper mapper,
                         IVoucherService voucherService)
 {
     _productService = productService;
     _mapper         = mapper;
     _voucherService = voucherService;
 }
Example #3
0
 public BillController(IBillService billService, IUsersService usersService, IVoucherService voucherService, IOfferService offerService)
 {
     this.billService    = billService;
     this.usersService   = usersService;
     this.voucherService = voucherService;
     this.offerService   = offerService;
 }
Example #4
0
 public HomeController(ICashbackService CashbackService, IGroupSiteService GroupSiteService, ILinked_SiteService Linked_SiteService, IVoucherService VoucherService)
 {
     this.CashbackService    = CashbackService;
     this.GroupSiteService   = GroupSiteService;
     this.Linked_SiteService = Linked_SiteService;
     this.VoucherService     = VoucherService;
 }
Example #5
0
 public VoucherController(IUnitOfWork db, IVoucherService voucherService, IOfferService offerService, IUserService userService)
 {
     this.db             = db;
     this.voucherService = voucherService;
     this.offerService   = offerService;
     this.userService    = userService;
 }
 public MerchantVoucherController(ApplicationDbContext context, UserManager <ApplicationUser> userManager,
                                  IVoucherService voucherService)
 {
     _context        = context;
     _userManager    = userManager;
     _voucherService = voucherService;
 }
Example #7
0
 //private IValueVoucherService valueVoucherService;
 public VoucherController(
     IVoucherService baseService)
 {
     // this.giftVoucher = giftService;
     // this.discountVoucher = discountService;
     this.baseVoucherService = baseService;
 }
 public BasketService(IOrderRepository orderRepository, IUserSessionService userSessionService,
                      IVoucherService voucherService)
 {
     _orderRepository    = orderRepository;
     _userSessionService = userSessionService;
     _voucherService     = voucherService;
 }
 public UserSessionService(IPizzaSizeRepository pizzaSizeRepository,
                           IToppingSizeRepository toppingSizeRepository, IVoucherService voucherService)
 {
     _pizzaSizeRepository   = pizzaSizeRepository;
     _toppingSizeRepository = toppingSizeRepository;
     _voucherService        = voucherService;
 }
Example #10
0
 public CustomerVoucherController(ApplicationDbContext context, UserManager <ApplicationUser> userManager,
                                  IVoucherService voucherService)
 {
     _userManager    = userManager;
     _voucherService = voucherService;
     _context        = context;
 }
 public HomeController(UserManager <ApplicationUser> userManager, ApplicationDbContext context,
                       IConfiguration configuration, IVoucherService voucherService)
 {
     _userManager    = userManager;
     _context        = context;
     _configuration  = configuration;
     _voucherService = voucherService;
 }
Example #12
0
 public VoucherAppService(IVoucherService voucherService, IVoucherRepository voucherRepository,
                          IVoucherHistoricDataRepository voucherHistoricDataRepository, IVoucherHistoricDataService voucherHistoricDataService)
 {
     VoucherService                = voucherService;
     VoucherRepository             = voucherRepository;
     VoucherHistoricDataService    = voucherHistoricDataService;
     VoucherHistoricDataRepository = voucherHistoricDataRepository;
 }
Example #13
0
 public UserSessionService(IPizzaSizeRepository pizzaSizeRepository,
                           IToppingSizeRepository toppingSizeRepository, IVoucherService voucherService)
 {
     _pizzaSizeRepository   = pizzaSizeRepository;
     _toppingSizeRepository = toppingSizeRepository;
     _voucherService        = voucherService;
     _userSessions          = new Dictionary <Guid, UserSessionData>();
 }
Example #14
0
 public PromotionsController(IPromotionService proSer, IAppliedPromotionService applySer,
                             IClaimedVoucherService claimedSer, IVoucherService vouSer)
 {
     _proSer     = proSer;
     _applySer   = applySer;
     _claimedSer = claimedSer;
     _vouSer     = vouSer;
 }
        public EventListViewModel(IVoucherService voucherService, INavigationService navigationService, IUIServices uiServices) : base(uiServices)
        {
            _voucherService    = voucherService;
            _navigationService = navigationService;

            GetEventsCommand = new DelegateCommand(GetEventsCommandAction);

            SelectEventCommand = new DelegateCommand <Models.Event>(SelectEventCommandAction);
        }
Example #16
0
 public BillController(IUnitOfWork db, IBillService billService, IOfferService offerService, IUserService userService, IVoucherService voucherService, IEmailsService emailsService)
 {
     this.db             = db;
     this.billService    = billService;
     this.offerService   = offerService;
     this.userService    = userService;
     this.voucherService = voucherService;
     this.emailsService  = emailsService;
 }
        public EventVoucherListViewModel(IVoucherService voucherService, INavigationService navigationService, IUIServices uiServices) : base(uiServices)
        {
            _voucherService    = voucherService;
            _navigationService = navigationService;

            FetchEventVoucherListCommand = new DelegateCommand(async() =>
            {
                Event.VoucherList = await _voucherService.GetVouchers(Event.Id);
            });
        }
 public OrderController(IMerchantService merchantService, ICustomerService customerService,
                        IPaymentService paymentService, IVoucherService voucherService, IConfiguration configuration)
 {
     _merchantService = merchantService;
     _customerService = customerService;
     _paymentService  = paymentService;
     _voucherService  = voucherService;
     _apiKey          = configuration.GetValue <string>("StripeApiKey");
     _endpointSecret  = configuration.GetValue <string>("StripeHookSecret");
 }
Example #19
0
        public EventVoucherListViewModel(IBaseRepository <Models.Voucher> voucherRepository, IVoucherService voucherService, INavigationService navigationService, IEventAggregator eventAggregator, IBarCodeService barCodeService, ITotpCodeService totpCodeService, IUIServices uiServices) : base(uiServices, navigationService)
        {
            _voucherService    = voucherService;
            _navigationService = navigationService;
            _eventAggregator   = eventAggregator;
            _barCodeService    = barCodeService;
            _totpCodeService   = totpCodeService;
            _voucherRepository = voucherRepository;

            GetEventVoucherListCommand = new DelegateCommand(GetEventVoucherListCommandAction);
        }
Example #20
0
        public EventListViewModel(IBaseRepository <Event> eventRepository, IBaseRepository <Store> storeRepository, IVoucherService voucherService, INavigationService navigationService, IUIServices uiServices) : base(uiServices, navigationService)
        {
            _voucherService    = voucherService;
            _navigationService = navigationService;
            _eventRepository   = eventRepository;
            _storeRepository   = storeRepository;

            GetEventsCommand           = new DelegateCommand(() => GetEventsCommandAction(false));
            GetEventsFromServerCommand = new DelegateCommand(() => GetEventsCommandAction(true));

            SelectEventCommand = new DelegateCommand <Models.Event>(SelectEventCommandAction);
        }
        public VoucherController()
        {
            var dbfactory = new DatabaseFactory();
            _anfVoucherService = new AnFVoucherService(new AnFVoucherRepository(dbfactory), new UnitOfWork(dbfactory));

            _anfVoucherDetailsService = new AnFVoucherDetailsService(new AnFVoucherDetailsRepository(dbfactory), new UnitOfWork(dbfactory));

            _cmnApprovalProcessService = new CmnApprovalProcessService(new CmnApprovalProcessRepository(dbfactory), new UnitOfWork(dbfactory));

            _cmnApprovalService = new CmnApprovalService(new CmnApprovalRepository(dbfactory), new CmnProcessLevelRepository(dbfactory), new UnitOfWork(dbfactory));
            _VoucherService = new VoucherService(new VoucherRepository(dbfactory), new VoucherDetailRepository(dbfactory), new UnitOfWork(dbfactory));
            _HrmEmployeeService = new HrmEmployeeService(new HrmEmployeeRepository(dbfactory), new UnitOfWork(dbfactory));
        }
 public VoucherController(
     IVoucherService voucherService,
     IMapper mapper,
     IEmailService emailService,
     IAccountService accountService,
     IViewRenderService viewRenderService,
     ILogger <VoucherController> logger)
 {
     _voucherService    = voucherService;
     _accountService    = accountService;
     _mapper            = mapper;
     _logger            = logger;
     _emailService      = emailService;
     _viewRenderService = viewRenderService;
 }
        //private object product;

        public OrderController(
            IProductService productService,
            IOrderService orderService,
            IVoucherService voucherService,
            IMapper mapper,
            IAccountService accountService,
            IEmailService emailService,
            IViewRenderService viewRenderService,
            ILogger <OrderController> logger)
        {
            _productService    = productService;
            _orderService      = orderService;
            _accountService    = accountService;
            _mapper            = mapper;
            _logger            = logger;
            _voucherService    = voucherService;
            _emailService      = emailService;
            _viewRenderService = viewRenderService;
        }
        private void CreateAndPostOrder(IVoucherService voucherService)
        {
            var createVoucher = new CreateVoucherDTO
            {
                vouchertypeId  = Properties.Settings.Default.VoucherTypeId,
                maxRedemptions = 0,
                firstName      = _customerDetailViewModel.FirstName,
                lastName       = _customerDetailViewModel.SecondName,
                email          = _customerDetailViewModel.Email
            };

            foreach (var itemLine in _cart.Lines)
            {
                var attribute = new AttributeDTO
                {
                    attributeId = itemLine.Experience.Code,
                    value       = itemLine.Quantity.ToString(),
                };
                createVoucher.attributes.Add(attribute);
            }

            var voucherDetail = voucherService.CreateVoucher(createVoucher).Result;

            _cart.Clear();

            var model = new VoucherDetailViewModel
            {
                VoucherToken       = voucherDetail.voucherToken,
                VoucherDescription = voucherDetail.voucherDescription,
                Name = voucherDetail.name,
                VoucherPurchasedOn = voucherDetail.voucherPurchasedOn,
                UsedOn             = voucherDetail.usedOn
            };

            _voucherDetailViewModel = null;
            _voucherDetailViewModel = model;
        }
Example #25
0
 public VoucherController(IVoucherService voucherService)
 {
     _voucherService = voucherService;
 }
Example #26
0
 public RemoteController(CosDbContext dbContext)
 {
     _memberService    = new MemberService(dbContext);
     _loginCodeService = new LoginCodeService(dbContext);
     _voucherService   = new VoucherService(dbContext);
 }
        public static PromotionRule checkPromotionRule(OrderAPIViewModel order, int quantity, OrderDetailAPIViewModel od)
        {
            #region call service
            IVoucherService         voucherService         = DependencyUtils.Resolve <IVoucherService>();
            IPromotionService       promotionService       = DependencyUtils.Resolve <IPromotionService>();
            IPromotionDetailService promotionDetailService = DependencyUtils.Resolve <IPromotionDetailService>();
            IProductService         productService         = DependencyUtils.Resolve <IProductService>();
            #endregion

            PromotionRule result = new PromotionRule
            {
                rule           = 0,
                discountAmount = 0
            };
            #region Voucher
            var voucher = voucherService.GetVoucherIsNotUsedAndCode(order.VoucherCode);
            if (voucher == null)
            {
                return(result);
            }
            #endregion


            //var voucher = voucherApi
            //TODO after have voucher
            int checkCountProduct = 0;//dùng check trường hợp gửi 2 đơn hàng giống nhau nhưng mỗi cái có 1 quantity

            //get date to get promotion is experied ??
            #region Promotion
            var      promotion = promotionService.GetPromotionByDateAndId(voucher.PromotionID);
            DateTime now       = DateTime.Now;

            if (promotion == null)
            {
                return(result);
            }
            else if (!(promotion.ApplyFromTime <= now.Hour && now.Hour <= promotion.ApplyToTime))
            {
                return(result);
            }

            #endregion
            #region PromtionDetail rule 1 min , max order???
            // loop to get total amount, final amount to get check in promotiondetail
            double finalAmount = 0;

            foreach (var item in order.OrderDetails)
            {
                finalAmount += (productService.GetProductById(item.ProductID).Price *item.Quantity);
            }

            var promotionDetail = promotionDetailService.GetDetailByCode(promotion.PromotionCode).FirstOrDefault();
            if (promotionDetail == null)
            {
                return(result);
            }
            //check promotion detail is have min, max order != null ???
            if (promotionDetail.MinOrderAmount != null || promotionDetail.MaxOrderAmount != null)
            {
                if (promotionDetail.MinOrderAmount != null && finalAmount < promotionDetail.MinOrderAmount)
                {
                    throw ApiException.Get(false, ConstantManager.MES_CREATE_ORDER_EXCEED_VOUCHER_MIN_MAX, ResultEnum.VoucherMin, HttpStatusCode.BadRequest);
                }
                else if (promotionDetail.MaxOrderAmount != null && finalAmount > promotionDetail.MaxOrderAmount)
                {
                    throw  ApiException.Get(false, ConstantManager.MES_CREATE_ORDER_EXCEED_VOUCHER_MIN_MAX, ResultEnum.VoucherMax, HttpStatusCode.BadRequest);
                }
                else
                {
                    try
                    {
                        double discountAmount = 0;//amount return
                        if (promotionDetail.DiscountRate != null && promotionDetail.DiscountRate > 0)
                        {
                            //nhân với phần trăm giảm giá và trả về số tiền lun
                            discountAmount = (productService.GetProductById(od.ProductID).Price *promotionDetail.DiscountRate.Value) / 100;
                        }
                        else if (promotionDetail.DiscountAmount != null && promotionDetail.DiscountAmount > 0)
                        {
                            //nếu giảm giá theo tiền mặt
                            discountAmount = Convert.ToDouble(promotionDetail.DiscountAmount.Value);
                        }
                        result.rule           = Models.ConstantManager.PROMOTION_RULE_1;
                        result.discountAmount = discountAmount;
                        return(result);
                    }
                    catch
                    {
                        result.rule           = 0;
                        result.discountAmount = 0;
                        return(result);
                    }
                }
            }
            #endregion

            #region rule 2 buy min, max quantity of each product
            else if (promotionDetail.BuyProductCode != null)
            {
                double discountAmount = 0;
                //check product code is in order ????
                bool checkProductCode = false;
                //list product discount
                List <ProductDiscount> listProductDiscount = new List <ProductDiscount>();
                // var pmDetail = promotionDetailApi.GetDetailByCode(promotion.PromotionCode);
                int     pDetailId         = voucher.PromotionDetailID == null ? 0 : voucher.PromotionDetailID.Value;
                var     pmDetail          = promotionDetailService.GetDetailById(pDetailId);
                decimal tmpDiscountAmount = 0;
                double  tmpDiscountRate   = 0;
                string  mesMinBuyProduct  = "";
                bool    checkCount        = true;//check quanitty min order buy
                var     tmpProductOrder   = productService.GetProductById(od.ProductID);

                bool checkCountProductQuantity = true; //false => đơn hàng gửi lên giống nhau nhưng ko đủ quantity min order,
                                                       //true => đơn hàng gửi lên giống nhau nhưng đủ quantity
                foreach (var item in order.OrderDetails)
                {
                    if (tmpProductOrder.Code == pmDetail.BuyProductCode)
                    {
                        checkCountProduct += item.Quantity;//cộng đồn quantity trong order
                        if (checkCountProduct < pmDetail.MinBuyQuantity)
                        {
                            checkCountProductQuantity = false;//false => đơn hàng gửi lên giống nhau nhưng ko đủ quantity min order,
                        }
                        else
                        {
                            checkCountProductQuantity = true;
                        }
                    }
                }
                if (pmDetail != null)
                {
                    if (tmpProductOrder.Code == pmDetail.BuyProductCode)
                    {
                        quantity         += od.Quantity;
                        tmpDiscountAmount = pmDetail.DiscountAmount == null ? 0 : pmDetail.DiscountAmount.Value * od.Quantity;
                        tmpDiscountRate   = pmDetail.DiscountRate == null ? 0 : pmDetail.DiscountRate.Value;
                        checkProductCode  = true;
                        if (quantity < pmDetail.MinBuyQuantity)
                        {
                            mesMinBuyProduct = pmDetail.MinBuyQuantity + " " + tmpProductOrder.ProductName;
                            checkCount       = false;
                        }
                    }
                    else
                    {
                        // checkCount = true;
                    }
                }

                try
                {
                    //if true => get list product discount
                    if (checkProductCode)
                    {
                        //check amount discount and rate, return value
                        if (tmpDiscountAmount > 0)
                        {
                            discountAmount = System.Convert.ToDouble(tmpDiscountAmount);
                        }
                        else if (tmpDiscountRate > 0)
                        {
                            discountAmount = (tmpProductOrder.Price * tmpDiscountRate * od.Quantity) / 100;
                        }
                    }
                    checkProductCode = false;
                    //return list product with discount amount, rate
                }
                catch
                {
                    result.rule           = 0;
                    result.discountAmount = 0;
                    result.quantity       = 0;
                    result.countProduct   = false;
                    return(result);
                }


                if (!checkCount && !checkCountProductQuantity)
                {
                    result.rule           = 0;
                    result.discountAmount = 0;
                    result.quantity       = quantity;
                    result.countProduct   = checkCountProductQuantity;
                    return(result);
                }
                result.rule           = ConstantManager.PROMOTION_RULE_2;
                result.discountAmount = discountAmount;
                result.quantity       = quantity;
                result.countProduct   = checkCountProductQuantity;
                return(result);
            }
            result.rule           = 0;
            result.discountAmount = 0;
            result.quantity       = 0;
            return(result);

            #endregion
        }
 public VoucherApiController(IVoucherService voucherService, ICertWordService certWordService)
 {
     _voucherService  = voucherService;
     _certWordService = certWordService;
 }
 public VoucherController(IVoucherService voucherService, ICart cart)
 {
     _cart           = cart;
     _voucherService = voucherService;
 }
Example #30
0
 public BasketService(IVoucherService voucherService)
 {
     _voucherService = voucherService;
 }
Example #31
0
 public VouchersController(IVoucherService VoucherService)
 {
     _VoucherService = VoucherService;
 }