Ejemplo n.º 1
0
        public JsonResult SaveWheelHistory(int priceId = -1)
        {
            int serverValidatorPrice = (int?)Session["CurrentPrice"] ?? -1;
            int defaultPoint         = int.Parse(ConfigurationManager.AppSettings["PointPerWheel"]);

            if (priceId == serverValidatorPrice)
            {
                var user       = _userService.ReadByGeneralUserId(User.Identity.GetUserId());
                var sumOfPoint = user.Point - defaultPoint;
                if (UserExternalService.IsUnluckyItem(priceId))
                {
                    _userService.UpdatePointUser(user.GeneralUserId, sumOfPoint);
                    return(Json(new { message = "Chúc bạn may mắn lần sau !", point = sumOfPoint, unLucky = true }, JsonRequestBehavior.AllowGet));
                }
                var desc = UserExternalService.GetDescriptonWheelItem(priceId);

                LuckyWheelHistoryDto h = new LuckyWheelHistoryDto()
                {
                    CreatedDate = DateTime.Now,
                    NameDisplay = user.NameDisplay,
                    UserId      = user.Id,
                    Result      = desc
                };

                var result = _userService.CreateLuckyHistory(h);
                if (result != null)
                {
                    _userService.UpdatePointUser(user.GeneralUserId, sumOfPoint);
                }
                return(Json(new { message = "Chúc mừng bạn đã trúng " + desc + ". Vui lòng inbox fanpage, Cám ơn bạn.", point = sumOfPoint }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { status = "error", message = "Xảy ra lỗi khi cập nhật thông tin, vui lòng quay số lại." }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult SellAccount(int accountId)
        {
            var account = _accountService.ReadOneById(accountId);
            var user    = _userService.ReadByGeneralUserId(User.Identity.GetUserId());

            if ((account.Price - ((account.Price * account.EventPrice) / 100)) > UserExternalService.GetUserBalance(User.Identity.GetUserId()))
            {
                return(RedirectToAction("ChargingView", "User",
                                        new { Message = "Tài khoản quý khách không đủ tiền, xin vui lòng nạp thêm. Cám ơn !" }));
            }
            try
            {
                _accountService.SoldAccount(accountId);

                //delete image
                FileUlti.DeleteFile(Server.MapPath("~") + account.Avatar.Substring(2));

                foreach (var page in account.NumberOfPageGems)
                {
                    FileUlti.DeleteFile(Server.MapPath("~") + page.ImageUrl.Substring(2));
                }

                var sumOfBalance = user.Balance - (account.Price - ((account.Price * account.EventPrice) / 100));
                _userService.UpdateBalanceUser(user.GeneralUserId, sumOfBalance);
            }
            catch (Exception)
            {
            }

            try
            {
                if (user != null)
                {
                    _historyService.Create(new UserTradingHistoryDto()
                    {
                        AccountId   = account.Id,
                        UserId      = user.Id,
                        CreatedDate = DateTime.Now
                    });
                }
            }
            catch (Exception)
            {
                throw;
            }



            AccountSoldViewModel vm = new AccountSoldViewModel()
            {
                AccountName = account.UserName,
                Password    = account.Password,
                Description = account.Description
            };

            return(View(vm));
        }
Ejemplo n.º 3
0
 public JsonResult GetRandomWheelItem()
 {
     if (UserExternalService.IsEnoughPoint(User.Identity.GetUserId()))
     {
         int resultForWheel;
         var result = _userService.RandomWheelItem(out resultForWheel);
         Session["CurrentPrice"] = result.Id;
         return(Json(resultForWheel, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { success = false, message = "Bạn không đủ số Point để quay, xin vui lòng nạp thêm thẻ. Cám ơn!" }, JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 4
0
        public async Task <ActionResult> ExternalLoginCallback(string returnUrl)
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

            if (loginInfo == null)
            {
                return(RedirectToAction("Login"));
            }

            // Sign in the user with this external login provider if the user already has a login
            var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent : false);

            var isActive = UserExternalService.GetUserStatus(loginInfo.ExternalIdentity.Claims.First(c => c.Type == "urn:facebook:id").Value);

            if (isActive != null && !(bool)isActive)
            {
                LogOff();
                return(RedirectToAction("LockNoticeView", "Home", new { userName = loginInfo.Email ?? loginInfo.DefaultUserName }));
            }

            switch (result)
            {
            case SignInStatus.Success:
                returnUrl = returnUrl ?? Url.Action("Index", "Home");
                if (returnUrl.Contains("ChargingView"))
                {
                    returnUrl = Url.Action("ChargingView", "User");
                }
                else if (returnUrl.ToLower().Contains("luckywheel"))
                {
                    returnUrl = Url.Action("LuckyWheel", "Home");
                }
                else if (returnUrl.ToLower().Contains("management"))
                {
                    returnUrl = Url.Action("AccountManagement", "Management");
                }
                return(RedirectToLocal(returnUrl));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false }));

            case SignInStatus.Failure:
            default:
                //if (string.IsNullOrEmpty(loginInfo.Email))
                //{
                //    return RedirectToAction("ExternalLoginConfirmationFacebook", new { email = "", returnUrl="" });
                //}
                // If the user does not have an account, then prompt the user to create an account

                returnUrl = returnUrl ?? Url.Action("Index", "Home");

                if (returnUrl.Contains("ChargingView"))
                {
                    returnUrl = Url.Action("ChargingView", "User");
                }
                else if (returnUrl.ToLower().Contains("luckywheel"))
                {
                    returnUrl = Url.Action("LuckyWheel", "Home");
                }
                else if (returnUrl.ToLower().Contains("management"))
                {
                    returnUrl = Url.Action("AccountManagement", "Management");
                }
                return(await ExternalLoginConfirmation(returnUrl));
            }
        }