Exemple #1
0
        // GET: Admin/ShopVersion
        public ActionResult Index(OneKeySearchModel searchModel)
        {
            //如果不是管理员,拒绝访问
            if (!CurrentInfo.IsAdministrator)
            {
                return(RedirectToAction("Error403", "Home", new { area = "Admin" }));
            }

            Expression <Func <ShopVersion, Boolean> > lbdWhere = null;

            if (searchModel.SearchStr != null)
            {
                searchModel.SearchStr = searchModel.SearchStr.Trim();
                if (!string.IsNullOrWhiteSpace(searchModel.SearchStr))
                {
                    lbdWhere = t => t.Name.Contains(searchModel.SearchStr);
                }
            }


            IShopVersionService shopVersionService = ServiceFactory.Create <IShopVersionService>();
            var shopVersions = shopVersionService.GetEntitiesByPage(searchModel.PageIndex, 20, lbdWhere, true, t => t.Short);

            ViewBag.SearchModel = searchModel;
            return(View(shopVersions));
        }
Exemple #2
0
        public ActionResult GetShopVersionByID(int ID)
        {
            IShopVersionService shopVersionService = ServiceFactory.Create <IShopVersionService>();
            var data = shopVersionService.GetEntity(ID);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public JsonResult ReDeleteShopVersion(int ID)
        {
            IShopVersionService shopVersionService = ServiceFactory.Create <IShopVersionService>();
            var data = shopVersionService.GetEntity(ID);

            data.Disabled = false;
            bool flage = shopVersionService.UpdateEntity(data);

            return(Json(new Result(flage, ResultType.Other), JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public JsonResult GetShopVersions()
        {
            IShopVersionService shopVersionService = ServiceFactory.Create <IShopVersionService>();

            var data = shopVersionService.GetEntities(t => t.Disabled == false).OrderBy(t => t.Short).Select(t => new
            {
                ID   = t.ID,
                Name = t.Name
            });

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public JsonResult AddShopVersion(ShopVersion shopVersionModel)
        {
            IShopVersionService shopVersionService = ServiceFactory.Create <IShopVersionService>();
            bool flage = shopVersionService.Exists(t => t.Name == shopVersionModel.Name);

            if (flage)
            {
                return(Json(new Result(false, "数据库已经存在同名角色"), JsonRequestBehavior.AllowGet));
            }

            shopVersionModel.CreateUserID = CurrentInfo.CurrentUser.ID;
            shopVersionModel.CreateTime   = DateTime.Now;
            var data = shopVersionService.AddEntity(shopVersionModel);

            return(Json(new Result(data != null, ResultType.Add), JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
        public ActionResult UpdateShopVersion(ShopVersion shopVersion)
        {
            IShopVersionService shopVersionService = ServiceFactory.Create <IShopVersionService>();
            bool flage = shopVersionService.Exists(t => t.ID != shopVersion.ID && t.Name == shopVersion.Name);

            if (flage)
            {
                return(Json(new Result(false, "数据库已经存在同名角色"), JsonRequestBehavior.AllowGet));
            }
            var dbData = shopVersionService.GetEntity(shopVersion.ID, false);

            shopVersion.CreateUserID = dbData.CreateUserID;
            shopVersion.CreateTime   = dbData.CreateTime;

            flage = shopVersionService.UpdateEntity(shopVersion);
            return(Json(new Result(flage, ResultType.Update), JsonRequestBehavior.AllowGet));
        }
Exemple #7
0
        public JsonResult DeleteShopVersions(string IDs)
        {
            List <int> idArr = IDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(t => Convert.ToInt32(t)).ToList();

            IShopVersionService shopVersionService = ServiceFactory.Create <IShopVersionService>();
            var  data    = shopVersionService.GetEntities(idArr);
            bool success = true;

            using (TransactionScope scope = TransactionScopeHelper.GetTran())
            {
                foreach (var item in data)
                {
                    item.Disabled = true;
                    bool flage = shopVersionService.UpdateEntity(item);
                    if (flage == false)
                    {
                        break;
                    }
                }
                scope.Complete();
            }

            return(Json(new Result(success, ResultType.Other), JsonRequestBehavior.AllowGet));
        }