Esempio n. 1
0
        public async Task <IActionResult> Save([Bind("ID,IsNew,Name,Telephone,SettledDateTime,Adress,Description,SortCode")] SK_WM_ShopVM shVM)
        {
            //var hasDuplicateNmaeShop = await _ShopRepository.HasInstanceAsyn(x => x.Name == shVM.Name);
            //if (hasDuplicateNmaeShop && shVM.IsNew)
            //{
            //    ModelState.AddModelError("", "店铺名称重复,无法添加。");
            //    return View("../../Views/Shop/ShopManager/CreateOrEdit", shVM);
            //}

            var sh = new SK_WM_Shop();

            if (!shVM.IsNew)
            {
                sh = await _ShopRepository.GetSingleAsyn(shVM.ID);
            }
            sh.SettledDateTime = shVM.SettledDateTime;
            shVM.MapToSh(sh);
            var saveStatus = await _ShopRepository.AddOrEditAndSaveAsyn(sh);

            if (saveStatus)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "数据保存出现异常,无法处理,请联系开发人员。");
                return(View("../../Views/Shop/ShopManager/CreateOrEdit", shVM));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 商家店铺信息设置
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> ShopSet()
        {
            var user = User.Claims.FirstOrDefault();

            if (user.Value == new Guid().ToString())
            {
                return(View("../../Views/Home/Logon"));
            }
            ViewBag.UserLogonInformation = GetUserName();
            //var userData = _UserManager.FindByIdAsync(user.Value);
            var ShopRepository = _ShopRepository.GetSingleBy(x => x.ShopForUser.Id == user.Value);
            var imgRepository  = await _ImageRepository.FindByAsyn(x => x.RelevanceObjectID == ShopRepository.ID);

            ViewBag.imgshopBanner = null;
            ViewBag.imgshopAvatar = null;
            foreach (var img in imgRepository)
            {
                if (img.Description == "shopBanner")
                {
                    ViewBag.imgshopBanner = img.UploadPath;
                }
                if (img.Description == "shopAvatar")
                {
                    ViewBag.imgshopAvatar = img.UploadPath;
                }
            }
            var shopVm = new SK_WM_ShopVM(ShopRepository);

            return(View("../../Views/BusinessOrganization/BusinessBG/ShopSet", shopVm));
        }
Esempio n. 3
0
        /// <summary>
        /// 以局部页的方式的方式,构建明细数据的处理
        /// </summary>
        /// <param name="id">店铺对象的ID属性值</param>
        /// <returns></returns>
        public async Task <IActionResult> Detail(Guid id)
        {
            var sh = await _ShopRepository.GetSingleAsyn(id);

            var shVM = new SK_WM_ShopVM(sh);

            return(PartialView("../../Views/Shop/ShopManager/_Detail", shVM));
        }
Esempio n. 4
0
        /// <summary>
        /// 执行违规操作(店铺)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> ExecuteIllegal(Guid id)
        {
            var isNew = false;
            var bo    = await _ShopRepository.GetSingleAsyn(id, x => x.ShopForUser);

            var shVM = new SK_WM_ShopVM(bo);

            shVM.IsNew = isNew;
            return(View("../../Views/Shop/ShopManager/_ShopIllegalExecute", shVM));
        }
Esempio n. 5
0
        public async Task <IActionResult> CreateOrEdit(Guid id)
        {
            var isNew = false;
            var sh    = await _ShopRepository.GetSingleAsyn(id);

            if (sh == null)
            {
                sh             = new SK_WM_Shop();
                sh.Name        = "";
                sh.Telephone   = "";
                sh.Adress      = "";
                sh.Description = "";
                sh.SortCode    = "";
                isNew          = true;
            }
            var shVM = new SK_WM_ShopVM(sh);

            shVM.IsNew = isNew;
            return(View("../../Views/Shop/ShopManager/CreateOrEdit", shVM));
        }
Esempio n. 6
0
        /// <summary>
        /// 商家店铺管理首页
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> IndexForShop(/*Guid id*/)
        {
            //var shopVM = await _ShopRepository.GetSingleAsyn(id);

            var shops = await _ShopRepository.GetAllAsyn();

            var shop = shops.FirstOrDefault();

            var shopVM = new SK_WM_ShopVM(shop);

            //var image = _ImageRepository.GetAll().OrderByDescending(x => x.SortCode).Where(y => y.RelevanceObjectID == shopVM.ID).FirstOrDefault();
            //if (image != null)
            //{
            //    shopVM.ShopAvatarPath = image.UploadPath;
            //}
            //shop.ShopAvatar = image;

            ViewBag.UserLogonInformation = GetUserName();
            return(View("../../Views/BusinessOrganization/AdminBG/IndexForShop", shopVM));
        }
Esempio n. 7
0
        public async Task <IActionResult> Index()
        {
            var username = User.Identity.Name;
            var user     = await _UserManager.FindByNameAsync(username);

            if (user == null)
            {
                return(View("../../Views/Home/Logon"));
            }
            var shop = await _ShopRepository.FindByAsyn(x => x.BelongToUserID == user.Id);

            if (shop.Count() == 0)
            {
                return(Redirect("../ShopManager/Settled"));
            }

            var boVM = new SK_WM_ShopVM(shop.FirstOrDefault());

            foreach (var state in Enum.GetValues(typeof(SK_WM_OrderState.Orderstate)))
            {
                if (state.ToString() == "待付款" || state.ToString() == "待发货" || state.ToString() == "待收货")
                {
                    if (state.ToString() == "待付款")
                    {
                        boVM.waitPay = GetCount(state.ToString(), shop.FirstOrDefault().Name);
                    }
                    else if (state.ToString() == "待发货")
                    {
                        boVM.waitSend = GetCount(state.ToString(), shop.FirstOrDefault().Name);
                    }
                    else if (state.ToString() == "待收货")
                    {
                        boVM.waitReceipt = GetCount(state.ToString(), shop.FirstOrDefault().Name);
                    }
                }
            }
            ViewBag.UserLogonInformation = GetUserName();

            return(View("../../Views/BusinessOrganization/BusinessBG/Index", boVM));
        }
Esempio n. 8
0
        /// <summary>
        /// 用于翻页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="objectTypeID"></param>
        /// <returns></returns>
        public async Task <IActionResult> IllegalShopPageList(int pageIndex, string objectTypeID)
        {
            var listPagePara = new ListPageParameter()
            {
                ObjectTypeID     = objectTypeID, // 对应的归属类型ID
                PageIndex        = pageIndex,    // 当前页码
                PageSize         = 8,            // 每页数据条数 为"0"时显示所有
                PageAmount       = 0,            // 相关对象列表分页处理分页数量
                ObjectAmount     = 0,            // 相关的对象的总数
                Keyword          = "",           // 当前的关键词
                SortProperty     = "SortCode",   // 排序属性
                SortDesc         = "default",    // 排序方向,缺省值正向 Default,前端用开关方式转为逆向:Descend
                SelectedObjectID = "",           // 当前页面处理中处理的焦点对象 ID
                IsSearch         = false,        // 当前是否为检索
            };

            var typeID  = "";
            var keyword = "";

            if (!String.IsNullOrEmpty(listPagePara.ObjectTypeID))
            {
                typeID = listPagePara.ObjectTypeID;
            }
            if (!String.IsNullOrEmpty(listPagePara.Keyword))
            {
                keyword = listPagePara.Keyword;
            }

            var username = User.Identity.Name;
            var user     = await _UserManager.FindByNameAsync(username);

            if (user == null)
            {
                return(View("../../Views/Home/Logon"));
            }
            var shCollection = await _ShopRepository.PaginateAsyn(listPagePara.PageIndex, listPagePara.PageSize, x => x.SortCode, null, x => x.ShopAvatar, x => x.ShopBanner, x => x.ShopForExecuteIllegal, x => x.ShopForUser);

            var shVMCollection = new List <SK_WM_ShopVM>();

            foreach (var sh in shCollection)
            {
                var shVM   = new SK_WM_ShopVM(sh);
                var images = _ImageRepository.GetAll().Where(x => x.RelevanceObjectID == sh.ID);
                foreach (var img in images)
                {
                    if (img.Description == "shopAvatar")
                    {
                        shVM.ShopAvatarPath = img.UploadPath;
                    }
                    if (img.Description == "shopBanner")
                    {
                        shVM.ShopBannerPath = img.UploadPath;
                    }
                }
                shVMCollection.Add(shVM);
            }
            var pageGroup = PagenateGroupRepository.GetItem <SK_WM_Shop>(shCollection, 10, listPagePara.PageIndex);

            ViewBag.PageGroup     = pageGroup;
            ViewBag.PageParameter = listPagePara;
            ViewBag.GoodsType     = "Admin";
            return(PartialView("../../Views/Shop/ShopManager/_List", shVMCollection));
        }
Esempio n. 9
0
        public async Task <IActionResult> Index()
        {
            ViewBag.UserLogonInformation = GetUserName();

            var listPagePara = new ListPageParameter()
            {
                ObjectTypeID     = "Shop",        // 对应的归属类型ID
                PageIndex        = 1,             // 当前页码
                PageSize         = 8,             // 每页数据条数 为"0"时显示所有
                PageAmount       = 0,             // 相关对象列表分页处理分页数量
                ObjectAmount     = 0,             // 相关的对象的总数
                Keyword          = "",            // 当前的关键词
                SortProperty     = "SortCode",    // 排序属性
                SortDesc         = "default",     // 排序方向,缺省值正向 Default,前端用开关方式转为逆向:Descend
                SelectedObjectID = "",            // 当前页面处理中处理的焦点对象 ID
                IsSearch         = false,         // 当前是否为检索
            };

            var typeID  = "";
            var keyword = "";

            if (!String.IsNullOrEmpty(listPagePara.ObjectTypeID))
            {
                typeID = listPagePara.ObjectTypeID;
            }
            if (!String.IsNullOrEmpty(listPagePara.Keyword))
            {
                keyword = listPagePara.Keyword;
            }

            //var shCollection = await _ShopRepository.GetAllIncludingAsyn(x => x.ShopForUser,x=>x.ShopAvatar, x => x.ShopBanner);
            var shCollection = await _ShopRepository.PaginateAsyn(listPagePara.PageIndex, listPagePara.PageSize, x => x.SortCode, null, x => x.ShopAvatar, x => x.ShopBanner, x => x.ShopForExecuteIllegal, x => x.ShopForUser);

            var shVMCollection = new List <SK_WM_ShopVM>();

            foreach (var sh in shCollection)
            {
                if (sh.ShopForExecuteIllegal.ShopState == (SK_WM_ShopState.ShopState.已开启).ToString())
                {
                    var shVM   = new SK_WM_ShopVM(sh);
                    var images = _ImageRepository.GetAll().Where(x => x.RelevanceObjectID == sh.ID);
                    foreach (var img in images)
                    {
                        if (img.Description == "shopAvatar")
                        {
                            shVM.ShopAvatarPath = img.UploadPath;
                        }
                        if (img.Description == "shopBanner")
                        {
                            shVM.ShopBannerPath = img.UploadPath;
                        }
                    }
                    shVMCollection.Add(shVM);
                }
            }
            var pageGroup = PagenateGroupRepository.GetItem <SK_WM_Shop>(shCollection, 10, listPagePara.PageIndex);

            ViewBag.PageGroup     = pageGroup;
            ViewBag.PageParameter = listPagePara;
            ViewBag.GoodsType     = "Admin";
            return(View("../../Views/Shop/ShopManager/Index", shVMCollection));
        }