예제 #1
0
        public ActionResult Handle(FormCollection collection)
        {
            var actionModules = _cache.Get(Constants.CACHE_KEY_ACTIONMODULE, () => _actionModule.GetList());

            var selectedModuleId = DataCast.Get <int>(collection["SelectedModuleId"]);
            var moduleIDs        = collection["ModuleId"];
            var roleId           = DataCast.Get <int>(collection["RoleId"]);
            var arrayModuleId    = moduleIDs.Split(',');

            var list = new List <RoleRightEntry>();

            foreach (var item in arrayModuleId)
            {
                var moduleId = int.Parse(item);
                var amList   = actionModules.Where(x => x.ModuleId == moduleId);
                foreach (var model in amList)
                {
                    var chkName   = "ActionModule_" + model.ActionModuleId;
                    var ramIdName = "RightId_" + model.ActionModuleId;

                    var chkVal  = collection[chkName];
                    var rightId = DataCast.Get <int>(collection[ramIdName]);

                    var info = new RoleRightEntry
                    {
                        ActionModuleId = model.ActionModuleId,
                        RoleId         = roleId,
                        RightId        = rightId,
                        Status         = chkVal == "on"
                    };

                    list.Add(info);
                }
            }

            var addList    = list.Where(x => x.RightId == 0);
            var updateList = list.Where(x => x.RightId != 0);

            Utility.Operate(this, Operations.Save, () =>
            {
                if (addList.Any())
                {
                    _roleRight.Add(addList);
                }

                if (updateList.Any())
                {
                    _roleRight.Update(updateList);
                }

                return(1);
            });


            return(Redirect(string.Format("~/Admin/RoleRights/Index/{0}?roleId={1}", selectedModuleId, roleId)));
        }
        public override List <CarrinhoProduto> CastToObject(SqlDataReader Reader)
        {
            List <CarrinhoProduto> Itens = new List <CarrinhoProduto>();

            while (Reader.Read())
            {
                Itens.Add(DataCast.CasCarrinhoProduto(Reader));
            }
            return(Itens);
        }
        public override List <Produto> CastToObject(SqlDataReader Reader)
        {
            List <Produto> Produtos = new List <Produto>();

            while (Reader.Read())
            {
                Produtos.Add(DataCast.CastProduto(Reader));
            }
            return(Produtos);
        }
        public override List <Categoria> CastToObject(SqlDataReader Reader)
        {
            List <Categoria> Categorias = new List <Categoria>();

            while (Reader.Read())
            {
                Categorias.Add(DataCast.CastCategoria(Reader));
            }
            return(Categorias);
        }
예제 #5
0
        public override List <Contadores> CastToObject(SqlDataReader Reader)
        {
            List <Contadores> Contadores = new List <Contadores>();

            while (Reader.Read())
            {
                Contadores.Add(DataCast.CastContadores(Reader));
            }
            return(Contadores);
        }
예제 #6
0
        public override List <Cliente> CastToObject(SqlDataReader Reader)
        {
            List <Cliente> Clientes = new List <Cliente>();

            while (Reader.Read())
            {
                Clientes.Add(DataCast.CastCliente(Reader));
            }
            return(Clientes);
        }
예제 #7
0
        public JsonResult Upload(FormCollection collection)
        {
            var model = new PhotoEntry();

            //获取上传文件队列
            var oFile = Request.Files["Filedata"];

            if (oFile != null)
            {
                string topDir = collection["folder"];  // 获取uploadify的folder配置,在此示例中,客户端配置了上传到 Files/ 文件夹
                // 检测并创建目录:当月上传的文件放到以当月命名的文件夹中,例如2011年11月的文件放到网站根目录下的 /Files/201111 里面

                string dateFolder      = Utility.GetUploadBasePath(topDir) + @"/" + DateTime.Now.Date.ToString("yyyyMM");
                string thumbnailFolder = dateFolder + @"/thumbnail";
                if (!Directory.Exists(dateFolder))         // 检测是否存在磁盘目录
                {
                    Directory.CreateDirectory(dateFolder); // 不存在的情况下,创建这个文件目录 例如 C:/wwwroot/Files/201111/
                }
                if (!Directory.Exists(thumbnailFolder))
                {
                    Directory.CreateDirectory(thumbnailFolder);
                }

                // 使用Guid命名文件,确保每次文件名不会重复
                string guidFileName = Guid.NewGuid() + Path.GetExtension(oFile.FileName).ToLower();
                // 保存文件,注意这个可是完整路径,例如C:/wwwroot/Files/201111/92b2ce5b-88af-405e-8262-d04b552f48cf.jpg
                var originalPath = dateFolder + @"/" + guidFileName;
                oFile.SaveAs(originalPath);

                var original = new DirectoryInfo(originalPath).FullName.Replace(AppDomain.CurrentDomain.BaseDirectory, "");

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //////// TODO 在此,您可以添加自己的业务逻辑,比如保存这个文件信息到数据库
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                var thumbnailPath = thumbnailFolder + @"/" + guidFileName;

                using (var file = System.IO.File.OpenRead(originalPath))
                {
                    PhotoUtils.CutForCustom(file, thumbnailPath, 380, 252, 50);
                }

                string thumbnail = new DirectoryInfo(thumbnailPath).FullName.Replace(AppDomain.CurrentDomain.BaseDirectory, "");
                var    newsId    = DataCast.Get <int>(collection["NewsId"]);


                model.Description = "请添加描述";
                model.NewsId      = newsId;
                model.Original    = @"~\" + original;
                model.Thumbnail   = @"~\" + thumbnail;
                _photo.Add(model);
            }

            return(Json(model));
        }
        public override List <Carrinho> CastToObject(SqlDataReader Reader)
        {
            List <Carrinho> Carrinhos = new List <Carrinho>();

            while (Reader.Read())
            {
                var carrinho = DataCast.CasCarrinho(Reader);
                using (var CarrinhoProdutoDao = new CarrinhoProdutoDao())
                {
                    carrinho.Produtos = CarrinhoProdutoDao.Select(carrinho.Id);
                }
                Carrinhos.Add(carrinho);
            }
            return(Carrinhos);
        }