Example #1
0
        public async Task ChangeShopDataAsync_PictureDoesNotChange_Ok(DbContextOptionsBuilder <ModelContext> builder)
        {
            var ctx      = this.GetModelContext(builder);
            var dbAccess = GetDbAccessInstance(ctx);
            var shop     = ShopUtils.GenerateShop();

            try
            {
                await ctx.Shops.AddAsync(shop);

                await ctx.SaveChangesAsync();

                var newDescription = shop.Description + "_changed";
                shop.SetDescription(newDescription);

                var changedShop = await dbAccess.ChangeShopDataAsync(shop.Id, shop);
            }
            finally
            {
                ctx.Shops.Remove(shop);
                await ctx.SaveChangesAsync();

                this.SetupFileStorageServiceMock(fssMock =>
                {
                    fssMock.Verify(s => s.StoreFileAsync(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <CancellationToken>()), Times.Never());
                });
            }
        }
Example #2
0
        public ActionResult AddAttributeGroup(AttributeGroupModel model, int cateId = -1)
        {
            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(cateId);

            if (categoryInfo == null)
            {
                return(PromptView("分类不存在"));
            }

            if (AdminCategories.GetAttributeGroupIdByCateIdAndName(cateId, model.AttributeGroupName) > 0)
            {
                ModelState.AddModelError("AttributeGroupName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                AttributeGroupInfo attributeGroupInfo = new AttributeGroupInfo()
                {
                    Name         = model.AttributeGroupName,
                    CateId       = categoryInfo.CateId,
                    DisplayOrder = model.DisplayOrder
                };

                AdminCategories.CreateAttributeGroup(attributeGroupInfo);
                AddAdminOperateLog("添加属性分组", "添加属性分组,属性分组为:" + model.AttributeGroupName);
                return(PromptView("属性分组添加成功"));
            }
            ViewData["cateId"]       = categoryInfo.CateId;
            ViewData["categoryName"] = categoryInfo.Name;
            ViewData["referer"]      = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #3
0
        public ActionResult EditAttribute(int attrId = -1)
        {
            AttributeInfo attributeInfo = AdminCategories.GetAttributeById(attrId);

            if (attributeInfo == null)
            {
                return(PromptView("属性不存在"));
            }

            AttributeModel model = new AttributeModel();

            model.AttributName = attributeInfo.Name;
            model.AttrGroupId  = attributeInfo.AttrGroupId;
            model.ShowType     = attributeInfo.ShowType;
            model.IsFilter     = attributeInfo.IsFilter;
            model.DisplayOrder = attributeInfo.DisplayOrder;

            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeInfo.CateId);

            ViewData["cateId"]             = categoryInfo.CateId;
            ViewData["categoryName"]       = categoryInfo.Name;
            ViewData["attributeGroupList"] = GetAttributeGroupSelectList(categoryInfo.CateId);
            ViewData["referer"]            = ShopUtils.GetAdminRefererCookie();

            return(View(model));
        }
Example #4
0
        /// <summary>
        /// 验证找回密码手机
        /// </summary>
        public ActionResult VerifyFindPwdMobile()
        {
            int    uid        = WebHelper.GetQueryInt("uid");
            string mobileCode = WebHelper.GetFormString("mobileCode");

            PartUserInfo partUserInfo = Users.GetPartUserById(uid);

            if (partUserInfo == null)
            {
                return(AjaxResult("nouser", "用户不存在"));
            }
            if (partUserInfo.Mobile.Length == 0)
            {
                return(AjaxResult("nocanfind", "由于您没有设置手机,所以不能通过手机找回此账号的密码"));
            }

            //检查手机码
            if (string.IsNullOrWhiteSpace(mobileCode))
            {
                return(AjaxResult("emptymobilecode", "手机验证码不能为空"));
            }
            else if (Sessions.GetValueString(WorkContext.Sid, "findPwdMoibleCode") != mobileCode)
            {
                return(AjaxResult("wrongmobilecode", "手机验证码不正确"));
            }

            string v   = ShopUtils.AESEncrypt(string.Format("{0},{1},{2}", partUserInfo.Uid, DateTime.Now, Randoms.CreateRandomValue(6)));
            string url = string.Format("http://{0}{1}", Request.Url.Authority, Url.Action("resetpwd", new RouteValueDictionary {
                { "v", v }
            }));

            return(AjaxResult("success", url));
        }
Example #5
0
        public ActionResult Add(BannedIPModel model)
        {
            string ip = "";

            if (string.IsNullOrWhiteSpace(model.IP4))
            {
                ip = string.Format("{0}.{1}.{2}", model.IP1, model.IP2, model.IP3);
            }
            else
            {
                ip = string.Format("{0}.{1}.{2}.{3}", model.IP1, model.IP2, model.IP3, model.IP4);
            }

            if (AdminBannedIPs.GetBannedIPIdByIP(ip) > 0)
            {
                ModelState.AddModelError("IP4", "IP已经存在");
            }

            if (ModelState.IsValid)
            {
                BannedIPInfo bannedIPInfo = new BannedIPInfo()
                {
                    IP          = ip,
                    LiftBanTime = model.LiftBanTime
                };

                AdminBannedIPs.AddBannedIP(bannedIPInfo);
                AddAdminOperateLog("添加禁止IP", "添加禁止IP,禁止IP为:" + ip);
                return(PromptView("禁止IP添加成功"));
            }
            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #6
0
        public ActionResult EditHelpCategory(HelpCategoryModel model, int id = -1)
        {
            HelpInfo helpInfo = AdminHelps.GetHelpById(id);

            if (helpInfo == null)
            {
                return(PromptView("帮助分类不存在"));
            }

            if (ModelState.IsValid)
            {
                helpInfo.Pid          = 0;
                helpInfo.Title        = model.HelpCategoryTitle;
                helpInfo.Url          = "";
                helpInfo.Description  = "";
                helpInfo.DisplayOrder = model.DisplayOrder;

                AdminHelps.UpdateHelp(helpInfo);
                AddAdminOperateLog("修改帮助分类", "修改帮助分类,帮助分类ID为:" + id);
                return(PromptView("帮助分类修改成功"));
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #7
0
        public ActionResult Add()
        {
            ShipCompanyModel model = new ShipCompanyModel();

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #8
0
        public ActionResult AddTimeProduct()
        {
            TimeProductModel model = new TimeProductModel();

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #9
0
        public ActionResult AddTimeProduct(TimeProductModel model)
        {
            PartProductInfo partProductInfo = AdminProducts.AdminGetPartProductById(model.Pid);

            if (partProductInfo == null)
            {
                ModelState.AddModelError("Pid", "请选择商品");
            }
            if (AdminProducts.IsExistTimeProduct(model.Pid))
            {
                ModelState.AddModelError("Pid", "此商品已经存在");
            }

            if (ModelState.IsValid)
            {
                DateTime        noTime          = new DateTime(1900, 1, 1);
                TimeProductInfo timeProductInfo = new TimeProductInfo()
                {
                    Pid          = model.Pid,
                    OnSaleState  = model.OnSaleTime == null ? 0 : 1,
                    OutSaleState = model.OutSaleTime == null ? 0 : 1,
                    OnSaleTime   = model.OnSaleTime == null ? noTime : model.OnSaleTime.Value,
                    OutSaleTime  = model.OutSaleTime == null ? noTime : model.OutSaleTime.Value
                };
                AdminProducts.AddTimeProduct(timeProductInfo);
                AddAdminOperateLog("添加定时商品", "添加定时商品,定时商品为:" + partProductInfo.Name);
                return(PromptView("定时商品添加成功"));
            }
            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #10
0
        public async Task GetShopAsync_Ok(DbContextOptionsBuilder <ModelContext> builder)
        {
            var ctx      = this.GetModelContext(builder);
            var dbAccess = GetDbAccessInstance(ctx);
            var shop     = ShopUtils.GenerateShop();

            this.SetupFileStorageServiceMock(fssMock =>
            {
                fssMock.Verify(s => s.GetFileAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never());
            });

            try
            {
                await ctx.Shops.AddAsync(shop);

                shop.SetCoverPicture(ShopUtils.VALID_COVERPICTURE);
                await ctx.SaveChangesAsync();

                var retrievedShop = await dbAccess.GetShopAsync(shop.Id);

                Assert.AreEqual(shop.Id, retrievedShop.Id);
            }
            finally
            {
                ctx.Shops.Remove(shop);
                await ctx.SaveChangesAsync();
            }
        }
Example #11
0
        public async Task AddShopAsync_CannotStorePicture_ShopNotCreated(DbContextOptionsBuilder <ModelContext> builder)
        {
            var ctx      = this.GetModelContext(builder);
            var dbAccess = GetDbAccessInstance(ctx);
            var shop     = ShopUtils.GenerateShop();

            this.SetupFileStorageServiceMock(fssMock =>
            {
                fssMock.Setup(s => s.StoreFileAsync(It.IsAny <string>(), shop.CoverPicture, It.IsAny <CancellationToken>())).Throws(new AccessViolationException());
            });

            var shopsCount = await ctx.Shops.CountAsync();

            try
            {
                var addedShop = await dbAccess.AddShopAsync(shop);

                Assert.Fail();
            }
            catch (AccessViolationException exc)
            {
                var shopsNewCount = await ctx.Shops.CountAsync();

                Assert.AreEqual(shopsCount, shopsNewCount);
            }
        }
Example #12
0
        public async Task AddShopAsync_Ok(DbContextOptionsBuilder <ModelContext> builder)
        {
            var ctx      = this.GetModelContext(builder);
            var dbAccess = GetDbAccessInstance(ctx);
            var shop     = ShopUtils.GenerateShop();

            try
            {
                var addedShop = await dbAccess.AddShopAsync(shop);

                var savedShop = await GetObjectFromDbAsync <Shop, int>(ctx, addedShop.Id);

                Assert.IsNotNull(savedShop);
            }
            finally
            {
                ctx.Shops.Remove(shop);
                await ctx.SaveChangesAsync();

                this.SetupFileStorageServiceMock(fssMock =>
                {
                    fssMock.Verify(s => s.StoreFileAsync(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <CancellationToken>()), Times.Once());
                });
            }
        }
Example #13
0
        public async Task DeleteShopAsync_Ok(DbContextOptionsBuilder <ModelContext> builder)
        {
            var ctx      = this.GetModelContext(builder);
            var dbAccess = GetDbAccessInstance(ctx);
            var shop     = ShopUtils.GenerateShop();
            int shopId   = -1;

            this.SetupFileStorageServiceMock(fssMock =>
            {
                fssMock.Verify(s => s.DeleteFileAsync(It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Once());
            });

            try
            {
                await ctx.Shops.AddAsync(shop);

                await ctx.SaveChangesAsync();

                shopId = shop.Id;

                await dbAccess.DeleteShopAsync(shopId);

                Assert.IsNull(await ctx.Shops.FindAsync(shopId));
            }
            finally
            {
                Shop delShop;
                if ((delShop = await ctx.Shops.FindAsync(shopId)) != null)
                {
                    ctx.Shops.Remove(delShop);
                    await ctx.SaveChangesAsync();
                }
            }
        }
Example #14
0
        public async Task ChangeShopDataAsync_ShopIdDoesNotExist_Throw(DbContextOptionsBuilder <ModelContext> builder)
        {
            var  ctx           = this.GetModelContext(builder);
            var  dbAccess      = GetDbAccessInstance(ctx);
            var  shop          = ShopUtils.GenerateShop();
            bool isShopDeleted = false;

            try
            {
                await ctx.Shops.AddAsync(shop);

                await ctx.SaveChangesAsync();

                ctx.Shops.Remove(shop);
                await ctx.SaveChangesAsync();

                isShopDeleted = true;

                await dbAccess.ChangeShopDataAsync(shop.Id, shop);
            }
            finally
            {
                if (!isShopDeleted)
                {
                    ctx.Shops.Remove(shop);
                    await ctx.SaveChangesAsync();
                }
            }
        }
Example #15
0
        public ActionResult AddNewsType()
        {
            NewsTypeModel model = new NewsTypeModel();

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #16
0
        public ActionResult EditTimeProduct(TimeProductModel model, int recordId = -1)
        {
            TimeProductInfo timeProductInfo = AdminProducts.GetTimeProductByRecordId(recordId);

            if (timeProductInfo == null)
            {
                return(PromptView("定时商品不存在"));
            }

            if (ModelState.IsValid)
            {
                DateTime noTime = new DateTime(1900, 1, 1);
                timeProductInfo.OnSaleTime  = model.OnSaleTime == null ? noTime : model.OnSaleTime.Value;
                timeProductInfo.OutSaleTime = model.OutSaleTime == null ? noTime : model.OutSaleTime.Value;

                if (model.OnSaleTime != timeProductInfo.OnSaleTime)
                {
                    timeProductInfo.OnSaleState = model.OnSaleTime == null ? 0 : 1;
                }
                if (model.OutSaleTime != timeProductInfo.OutSaleTime)
                {
                    timeProductInfo.OutSaleState = model.OutSaleTime == null ? 0 : 1;
                }

                AdminProducts.UpdateTimeProduct(timeProductInfo);
                AddAdminOperateLog("修改定时商品", "修改定时商品,定时商品ID为:" + timeProductInfo.Pid);
                return(PromptView("定时商品修改成功"));
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #17
0
        public ActionResult EditNewsType(NewsTypeModel model, int newsTypeId = -1)
        {
            NewsTypeInfo newsTypeInfo = AdminNews.GetNewsTypeById(newsTypeId);

            if (newsTypeInfo == null)
            {
                return(PromptView("新闻类型不存在"));
            }

            NewsTypeInfo newsTypeInfo2 = AdminNews.GetNewsTypeByName(model.NewsTypeName);

            if (newsTypeInfo2 != null && newsTypeInfo2.NewsTypeId != newsTypeId)
            {
                ModelState.AddModelError("NewsTypeName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                newsTypeInfo.Name         = model.NewsTypeName;
                newsTypeInfo.DisplayOrder = model.DisplayOrder;

                AdminNews.UpdateNewsType(newsTypeInfo);
                AddAdminOperateLog("修改新闻类型", "修改新闻类型,新闻类型ID为:" + newsTypeId);
                return(PromptView("新闻类型修改成功"));
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #18
0
        /// <summary>
        /// 下架商品列表
        /// </summary>
        /// <param name="productName">商品名称</param>
        /// <param name="categoryName">分类名称</param>
        /// <param name="brandName">品牌名称</param>
        /// <param name="cateId">分类id</param>
        /// <param name="brandId">品牌id</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="pageSize">每页数</param>
        /// <returns></returns>
        public ActionResult OutSaleProductList(string productName, string categoryName, string brandName, int cateId = -1, int brandId = -1, int pageNumber = 1, int pageSize = 15)
        {
            string condition = AdminProducts.AdminGetProductListCondition(productName, cateId, brandId, (int)ProductState.OutSale);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminProducts.AdminGetProductCount(condition));

            ProductListModel model = new ProductListModel()
            {
                PageModel    = pageModel,
                ProductList  = AdminProducts.AdminGetProductList(pageModel.PageSize, pageModel.PageNumber, condition),
                CateId       = cateId,
                CategoryName = string.IsNullOrWhiteSpace(categoryName) ? "全部分类" : categoryName,
                BrandId      = brandId,
                BrandName    = string.IsNullOrWhiteSpace(brandName) ? "全部品牌" : brandName,
                ProductName  = productName
            };

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&ProductName={3}&cateId={4}&brandId={5}&categoryName={6}&brandName={7}",
                                                          Url.Action("outsaleproductlist"),
                                                          pageModel.PageNumber, pageModel.PageSize,
                                                          productName,
                                                          cateId, brandId,
                                                          categoryName, brandName));
            return(View(model));
        }
Example #19
0
        public ActionResult AddHelpCategory()
        {
            HelpCategoryModel model = new HelpCategoryModel();

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #20
0
        /// <summary>
        /// 用户充值记录
        /// </summary>
        public ActionResult RemitList(string Account = "", string type = "", int pageSize = 15, int pageNumber = 1)
        {
            ShopUtils.SetAdminRefererCookie(Url.Action("remitlist"));
            StringBuilder strb = new StringBuilder();

            strb.Append(" where 1=1");
            if (Account != string.Empty)
            {
                strb.Append(" and (rtrim(b.mobile)='" + Account + "' or username like '%" + Account + "%')");
            }
            if (type != string.Empty)
            {
                strb.Append(" and a.type='" + type + "'");
            }
            List <MD_Remit> remitlist = NewUser.GetUserRemitList(pageNumber, pageSize, strb.ToString());
            UserRemitList   model     = new UserRemitList()
            {
                Account   = Account,
                type      = type,
                RemitList = remitlist,
                PageModel = new PageModel(pageSize, pageNumber, remitlist.Count > 0 ? remitlist[0].TotalCount : 0)
            };

            return(View(model));
        }
Example #21
0
        public ActionResult Edit(ShipCompanyModel model, int shipCoId = -1)
        {
            ShipCompanyInfo shipCompanyInfo = AdminShipCompanies.GetShipCompanyById(shipCoId);

            if (shipCompanyInfo == null)
            {
                return(PromptView("配送公司不存在"));
            }

            int shipCoId2 = AdminShipCompanies.GetShipCoIdByName(model.CompanyName);

            if (shipCoId2 > 0 && shipCoId2 != shipCoId)
            {
                ModelState.AddModelError("CompanyName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                shipCompanyInfo.DisplayOrder = model.DisplayOrder;
                shipCompanyInfo.Name         = model.CompanyName;

                AdminShipCompanies.UpdateShipCompany(shipCompanyInfo);
                AddAdminOperateLog("修改配送公司", "修改配送公司,配送公司ID为:" + shipCoId);
                return(PromptView("配送公司修改成功"));
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #22
0
        public ActionResult AddRemit(UserRemit remit)
        {
            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            if (!Users.IsExistMobile(remit.Mobile))
            {
                return(PromptView("账号不存在"));
            }
            PartUserInfo user = Users.GetPartUserByMobile(remit.Mobile);
            MD_Remit     rmt  = new MD_Remit
            {
                Uid     = user.Uid,
                Mobile  = remit.Mobile,
                Type    = "人工充值",
                Name    = "系统充值",
                Account = "系统充值",
                Money   = remit.Money,
                Status  = 0
            };
            bool addres = NewUser.AddUserRemit(rmt);

            if (addres)
            {
                return(PromptView("添加成功"));
            }
            else
            {
                return(PromptView("添加失败"));
            }
        }
Example #23
0
        public ActionResult Add()
        {
            BannedIPModel model = new BannedIPModel();

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #24
0
        public ActionResult UserBankList(string Account = "", string UserName = "", int pageSize = 15, int pageNumber = 1)
        {
            ShopUtils.SetAdminRefererCookie(Url.Action("userbanklist"));
            StringBuilder strb = new StringBuilder();

            strb.Append(" where 1=1");
            if (Account != string.Empty)
            {
                strb.Append(" and (rtrim(b.mobile)='" + Account + "' or b.username like '%" + Account + "%')");
            }
            if (UserName != string.Empty)
            {
                strb.Append(" and a.username = '******'");
            }

            List <MD_DrawAccount> list     = Recharge.GetDrawAccountList(pageNumber, pageSize, strb.ToString());
            UserBankListModel     userlist = new UserBankListModel
            {
                Mobile    = Account,
                UserName  = UserName,
                PageModel = new PageModel(pageSize, pageNumber, list.Count > 0 ? list[0].TotalCount : 0),
                BankList  = list
            };

            return(View(userlist));
        }
Example #25
0
        private void Load(int regionId)
        {
            List <SelectListItem> adminGroupList = new List <SelectListItem>();

            adminGroupList.Add(new SelectListItem()
            {
                Text = "选择管理员组", Value = "0"
            });
            foreach (AdminGroupInfo info in AdminGroups.GetAdminGroupList())
            {
                adminGroupList.Add(new SelectListItem()
                {
                    Text = info.Title, Value = info.AdminGid.ToString()
                });
            }
            ViewData["adminGroupList"] = adminGroupList;

            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo != null)
            {
                ViewData["provinceId"] = regionInfo.ProvinceId;
                ViewData["cityId"]     = regionInfo.CityId;
                ViewData["countyId"]   = regionInfo.RegionId;
            }
            else
            {
                ViewData["provinceId"] = -1;
                ViewData["cityId"]     = -1;
                ViewData["countyId"]   = -1;
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
        }
Example #26
0
        /// <summary>
        /// 验证图片
        /// </summary>
        /// <param name="width">图片宽度</param>
        /// <param name="height">图片高度</param>
        /// <returns></returns>
        public ImageResult VerifyImage(int width = 56, int height = 20)
        {
            //获得用户唯一标示符sid
            string sid = ShopUtils.GetSidCookie("web");

            //当sid为空时
            if (sid == null)
            {
                //生成sid
                sid = Sessions.GenerateSid();
                //将sid保存到cookie中
                ShopUtils.SetSidCookie(sid, "web");
            }

            //生成验证值
            string verifyValue = Randoms.CreateRandomValue(4, false).ToLower();
            //生成验证图片
            RandomImage verifyImage = Randoms.CreateRandomImage(verifyValue, width, height, Color.White, Color.Blue, Color.DarkRed);

            //将验证值保存到session中
            Sessions.SetItem(sid, "verifyCode", verifyValue);

            //输出验证图片
            return(new ImageResult(verifyImage.Image, verifyImage.ContentType));
        }
Example #27
0
        public ActionResult EditAttributeGroup(AttributeGroupModel model, int attrGroupId = -1)
        {
            AttributeGroupInfo attributeGroupInfo = AdminCategories.GetAttributeGroupById(attrGroupId);

            if (attributeGroupInfo == null)
            {
                return(PromptView("属性分组不存在"));
            }

            int attrGroupId2 = AdminCategories.GetAttributeGroupIdByCateIdAndName(attributeGroupInfo.CateId, model.AttributeGroupName);

            if (attrGroupId2 > 0 && attrGroupId2 != attrGroupId)
            {
                ModelState.AddModelError("AttributeGroupName", "名称已经存在");
            }

            if (ModelState.IsValid)
            {
                attributeGroupInfo.Name         = model.AttributeGroupName;
                attributeGroupInfo.DisplayOrder = model.DisplayOrder;

                AdminCategories.UpdateAttributeGroup(attributeGroupInfo);
                AddAdminOperateLog("修改属性分组", "修改属性分组,属性分组ID为:" + attrGroupId);
                return(PromptView("属性分组修改成功"));
            }

            CategoryInfo categoryInfo = AdminCategories.GetCategoryById(attributeGroupInfo.CateId);

            ViewData["cateId"]       = categoryInfo.CateId;
            ViewData["categoryName"] = categoryInfo.Name;
            ViewData["referer"]      = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Example #28
0
        /// <summary>
        /// 管理员操作日志列表
        /// </summary>
        /// <param name="accountName">操作人</param>
        /// <param name="operation">操作动作</param>
        /// <param name="startTime">操作开始时间</param>
        /// <param name="endTime">操作结束时间</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="pageSize">每页数</param>
        /// <returns></returns>
        public ActionResult AdminOperateLogList(string accountName, string operation, string startTime, string endTime, int pageNumber = 1, int pageSize = 15)
        {
            int uid = AdminUsers.GetUidByAccountName(accountName);

            string condition = AdminOperateLogs.GetAdminOperateLogListCondition(uid, operation, startTime, endTime);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminOperateLogs.GetAdminOperateLogCount(condition));

            AdminOperateLogListModel model = new AdminOperateLogListModel()
            {
                PageModel           = pageModel,
                AdminOperateLogList = AdminOperateLogs.GetAdminOperateLogList(pageModel.PageSize, pageModel.PageNumber, condition),
                AccountName         = accountName,
                Operation           = operation,
                StartTime           = startTime,
                EndTime             = endTime
            };

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&accountName={3}&operation={4}&startTime={5}&endTime={6}",
                                                          Url.Action("adminoperateloglist"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          accountName, operation, startTime, endTime));
            return(View(model));
        }
Example #29
0
        public ActionResult EditAttributeValue(int attrValueId = -1)
        {
            AttributeValueInfo attributeValueInfo = AdminCategories.GetAttributeValueById(attrValueId);

            if (attributeValueInfo == null)
            {
                return(PromptView("属性值不存在"));
            }
            if (attributeValueInfo.IsInput == 1)
            {
                return(PromptView("输入型属性值不能修改"));
            }

            AttributeValueModel model = new AttributeValueModel();

            model.AttrValue    = attributeValueInfo.AttrValue;
            model.DisplayOrder = attributeValueInfo.AttrValueDisplayOrder;

            AttributeInfo attributeInfo = Categories.GetAttributeById(attributeValueInfo.AttrId);

            ViewData["attrId"]        = attributeInfo.AttrId;
            ViewData["attributeName"] = attributeInfo.Name;
            ViewData["referer"]       = ShopUtils.GetAdminRefererCookie();

            return(View(model));
        }
Example #30
0
        public async Task ChangeShopDataAsync_Ok(DbContextOptionsBuilder <ModelContext> builder)
        {
            var ctx = this.GetModelContext(builder);
            var dbAccess = GetDbAccessInstance(ctx);
            var shop = ShopUtils.GenerateShop();
            var newCoverPicture = new byte[] { 0x01 }.ToArray();

            try
            {
                await ctx.Shops.AddAsync(shop);

                await ctx.SaveChangesAsync();

                var newDescription = shop.Description + "_changed";
                shop.SetDescription(newDescription);
                shop.SetCoverPicture(newCoverPicture);

                var changedShop = await dbAccess.ChangeShopDataAsync(shop.Id, shop);

                Shop changedShopFromDb = await GetObjectFromDbAsync <Shop, int>(ctx, shop.Id);

                Assert.AreEqual(newDescription, changedShopFromDb.Description);
                CollectionAssert.AreEqual(newCoverPicture, changedShop.CoverPicture);
            }
            finally
            {
                ctx.Shops.Remove(shop);
                await ctx.SaveChangesAsync();

                this.SetupFileStorageServiceMock(fssMock =>
                {
                    fssMock.Verify(s => s.StoreFileAsync(It.IsAny <string>(), newCoverPicture, It.IsAny <CancellationToken>()), Times.Once());
                });
            }
        }