public ActionResult Index()
        {
            var email = User.Identity.Name;
            var user  = new UserAuthVM(email);

            return(View(user));
        }
Beispiel #2
0
        public JsonResult AjaxSubmitCoupon()
        {
            string dataString = Request.Form["Data"];

            dataString = HttpUtility.UrlDecode(dataString);
            Coupon info = ECommerce.Utility.SerializationUtility.JsonDeserialize2 <Coupon>(dataString);

            SetBizEntityUserInfo(info, info.SysNo.HasValue ? false : true);

            UserAuthVM user = UserAuthHelper.GetCurrentUser();

            if (user == null)
            {
                throw new ECommerce.Utility.BusinessException();
            }
            info.Status        = CouponStatus.WaitingAudit;
            info.MerchantSysNo = user.SellerSysNo;
            info.EditUser      = user.UserID;
            info.InUser        = user.UserID;
            if (info.SysNo.HasValue && info.SysNo > 0)
            {
                info = CouponService.Update(info);
            }
            else
            {
                info = CouponService.Create(info);
            }

            return(Json(new { Data = info }));
        }
Beispiel #3
0
        public JsonResult AjaxLoadCoupon()
        {
            string CouponSysNoStr = Request["CouponSysNo"];
            int    CouponSysNo    = 0;

            int.TryParse(CouponSysNoStr, out CouponSysNo);
            if (CouponSysNo < 1)
            {
                throw new ECommerce.Utility.BusinessException(LanguageHelper.GetText("数据无效"));
            }
            UserAuthVM user = UserAuthHelper.GetCurrentUser();

            if (user == null)
            {
                throw new ECommerce.Utility.BusinessException();
            }
            Coupon info = CouponService.Load(CouponSysNo);

            if (info != null)
            {
                if (info.MerchantSysNo != user.SellerSysNo)
                {
                    throw new ECommerce.Utility.BusinessException(LanguageHelper.GetText("您没有权限访问该数据"));
                }
            }

            return(Json(info));
        }
        public IActionResult Login([FromBody] UserAuthVM user)
        {
            if (user == null)
            {
                return(BadRequest("Solitud del cliente invalida."));
            }

            if (user.UserName == "user" && user.Password == "12345")
            {
                var secretKey          = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration[ConfigurationConstants.JWT_KEY]));
                var signingCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256);

                var tokenOptions = new JwtSecurityToken(
                    issuer: configuration[ConfigurationConstants.JWT_ISSUER],
                    audience: configuration[ConfigurationConstants.JWT_ISSUER],
                    claims: new List <Claim>(),
                    expires: DateTime.Now.AddMinutes(5),
                    signingCredentials: signingCredentials
                    );

                var tokenString = new JwtSecurityTokenHandler().WriteToken(tokenOptions);
                return(Ok(new { Token = tokenString }));
            }
            else
            {
                return(Unauthorized());
            }
        }
Beispiel #5
0
        public ControllerBase()
        {
            this.ViewBag.IsUserLogin = UserAuthHelper.HasLogin();
            //加载登录信息
            var userInfo = UserAuthHelper.GetCurrentUser();

            if (userInfo != null)
            {
                this.ViewBag.CurrUser = userInfo;
                CurrUser = userInfo;
            }
        }
Beispiel #6
0
        public JsonResult AjaxCreateCouponCode(int CouponSysNo)
        {
            UserAuthVM user = UserAuthHelper.GetCurrentUser();

            if (user == null)
            {
                throw new ECommerce.Utility.BusinessException();
            }
            string code = CouponService.GenerateRandomCode(10);

            return(Json(code));
        }
Beispiel #7
0
        public JsonResult AjaxStopCoupon(int CouponSysNo)
        {
            UserAuthVM user = UserAuthHelper.GetCurrentUser();

            if (user == null)
            {
                throw new ECommerce.Utility.BusinessException();
            }
            CouponService.StopCoupon(CouponSysNo, user.SellerSysNo, user.UserID);

            return(Json(new { Data = true }));
        }
Beispiel #8
0
        public JsonResult AjaxBatchStopCoupon()
        {
            UserAuthVM user = UserAuthHelper.GetCurrentUser();

            if (user == null)
            {
                throw new ECommerce.Utility.BusinessException();
            }
            string dataString = Request.Form["Data"];

            dataString = HttpUtility.UrlDecode(dataString);
            var CouponSysNos = ECommerce.Utility.SerializationUtility.JsonDeserialize2 <int[]>(dataString);

            {
                int    merchantSysNo = user.SellerSysNo;
                string userName      = user.UserID;
                if (CouponSysNos == null || CouponSysNos.Length < 1)
                {
                    throw new BusinessException(LanguageHelper.GetText("批量操作数据不能为空"));
                }
                StringBuilder sb           = new StringBuilder();
                int           errorCount   = 0;
                int           successCount = 0;
                foreach (int CouponSysNo in CouponSysNos)
                {
                    try
                    {
                        CouponService.StopCoupon(CouponSysNo, merchantSysNo, userName);
                        successCount++;
                    }
                    catch (BusinessException ex)
                    {
                        sb.AppendLine(string.Format(LanguageHelper.GetText("活动编号:{0} {1}<br/>"), CouponSysNo, ex.Message));
                        errorCount++;
                    }
                    catch (Exception ex)
                    {
                        sb.AppendLine(string.Format(LanguageHelper.GetText("活动编号:{0} {1}<br/>"), CouponSysNo, ex.Message));
                        errorCount++;
                    }
                }
                if (sb.Length > 0)
                {
                    StringBuilder exMessage = new StringBuilder();
                    exMessage.AppendLine(string.Format(LanguageHelper.GetText("操作已完成!成功{0}条,失败{1}条<br/>"), successCount, errorCount));
                    exMessage.AppendLine(sb.ToString());

                    throw new BusinessException(exMessage.ToString());
                }
            }
            return(Json(new { Data = true }));
        }
Beispiel #9
0
        public JsonResult AjaxBitchCreateCouponCode(int Num)
        {
            string     code = "";
            UserAuthVM user = UserAuthHelper.GetCurrentUser();

            if (user == null)
            {
                throw new ECommerce.Utility.BusinessException();
            }
            for (int i = 0; i < Num; i++)
            {
                code += CouponService.GenerateRandomCode(10) + "\n";
            }
            return(Json(code));
        }
Beispiel #10
0
        public JsonResult SaveFrontProductCategory(FrontProductCategoryInfo info)
        {
            JsonResult result = new JsonResult();

            if (info != null)
            {
                UserAuthVM user = UserAuthHelper.GetCurrentUser();
                if (user != null)
                {
                    info.SellerSysNo   = user.SellerSysNo;
                    info.InUserSysNo   = user.UserSysNo;
                    info.InUserName    = user.UserDisplayName;
                    info.EditUserSysNo = user.UserSysNo;
                    info.EditUserName  = user.UserDisplayName;
                }
            }
            result.Data = ProductService.SaveFrontProductCategory(info);
            return(result);
        }