Exemplo n.º 1
0
        public IActionResult MyPackage()
        {
            CustomerCard    card    = _cardService.GetCurrentUserCard(_userManager.GetUserId(HttpContext.User));
            Package         package = _packageService.GetById(card.Package.Id);
            SetBox          SetBox  = _sbService.GetById(card.SetBox.Id);
            Customer        cus     = _cusService.GetByUser(_userManager.GetUserId(HttpContext.User));
            DateTime        expire  = _cpService.GetExpirationTime(cus.Id);
            CustomerPackage cp      = _cpService.GetByCardId(card.Id);

            string status = UpdatePakageStatus(cp, expire);

            MyPackageViewModel model = new MyPackageViewModel
            {
                MyPackage = new PackageDetailViewModel
                {
                    PackageName  = package.PackageName,
                    NoOfChannels = package.NoOfChannels,
                    Charges      = package.Charges,
                    ImageUrl     = package.ImageUrl
                },
                MySetBox = new SetBoxDetailModel
                {
                    Name          = SetBox.Name,
                    Specification = SetBox.Specification,
                    Price         = SetBox.Price,
                    ImageUrl      = SetBox.ImageUrl
                },
                GetExpiration = expire,
                State         = status
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                var card = _cardService.GetCardByNumber(model.Customercard);

                if (!_customerService.IsCustomer(card.Id))
                {
                    var user = new ApplicationUser {
                        UserName = model.Email, Email = model.Email
                    };
                    var result = await _userManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        Customer cus = new Customer
                        {
                            ApplicationUser = user,
                            CustomerCard    = card,
                            CustomerName    = card.OwnerName
                        };

                        _customerService.Add(cus);

                        CustomerPackage cp = _customerPackage.GetByCardId(card.Id);
                        cp.Customer = cus;
                        _customerPackage.Update(cp);
                        await _userManager.AddToRoleAsync(user, "User");
                    }

                    if (result.Succeeded)
                    {
                        _logger.LogInformation("User created a new account with password.");

                        var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                        var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                        await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl);

                        await _signInManager.SignInAsync(user, isPersistent : false);

                        _logger.LogInformation("User created a new account with password.");
                        return(RedirectToLocal(returnUrl));
                    }
                    AddErrors(result);
                }
                ModelState.AddModelError(model.Customercard, "User account already exists on this card number");
                return(View(model));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 3
0
        public IActionResult Index(RechargeAddModel model)
        {
            DateTime now = DateTime.Now;

            if (model.CardExpiry < now)
            {
                ModelState.AddModelError("CardExpiry", "Your Credit Card is Expire");
                return(View(model));
            }
            if (ModelState.IsValid)
            {
                var card    = GetCard(model.Customercard);
                var package = GetPackage(card.Package.Id);

                Recharge recharge = new Recharge()
                {
                    CardExpiry       = model.CardExpiry,
                    Cost             = model.Total,
                    CreditCardNumber = model.CreditCardNumber,
                    CVV          = model.CVV,
                    PaymentType  = model.PaymentType,
                    RechargeDate = now,
                    CustomerCard = card,
                    Package      = package
                };

                var cp = _cpService.GetByCardId(card.Id);
                cp.Status         = _statusService.GetByName("Charged");
                cp.ExpirationDate = now.AddMonths(model.Months);
                cp.NumberOfMonths = model.Months;
                cp.Package        = card.Package;
                cp.CustomerCard   = card;

                _cpService.Update(cp);
                _rechargeService.Add(recharge);

                ModelState.Clear();
                ViewBag.success = "success";
                ViewBag.msg     = "Your Account has been Recharge ,Thank You! for chossing our service";
                return(View());
            }

            return(View(model));
        }