//
        // GET: /BaseData/BaseAttributeCategory/Detail
        public async Task <ActionResult> Detail(string name)
        {
            using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
            {
                MethodReturnResult <BaseAttributeCategory> result = await client.GetAsync(name);

                if (result.Code == 0)
                {
                    BaseAttributeCategoryViewModel viewModel = new BaseAttributeCategoryViewModel()
                    {
                        Name        = result.Data.Key,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Description = result.Data.Description,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
        public async Task <ActionResult> Query(BaseAttributeCategoryQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.CategoryName))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.CategoryName);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <BaseAttributeCategory> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Ejemplo n.º 3
0
        //
        // GET: /BaseData/BaseAttributeValue/
        public async Task <ActionResult> Index(string categoryName)
        {
            using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
            {
                MethodReturnResult <BaseAttributeCategory> result = await client.GetAsync(categoryName ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "BaseAttributeCategory"));
                }
                ViewBag.BaseAttributeCategory = result.Data;
            }

            using (BaseAttributeServiceClient client = new BaseAttributeServiceClient())
            {
                await Task.Run(() =>
                {
                    string where     = string.Format("Key.CategoryName='{0}'", categoryName);
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Key.CategoryName,Order",
                        Where    = where
                    };
                    MethodReturnResult <IList <BaseAttribute> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.BaseAttributeList = result.Data;
                    }
                });
            }
            using (BaseAttributeValueServiceClient client = new BaseAttributeValueServiceClient())
            {
                await Task.Run(() =>
                {
                    string where     = string.Format("Key.CategoryName='{0}'", categoryName);
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Key.CategoryName,Key.ItemOrder",
                        Where    = where
                    };
                    MethodReturnResult <IList <BaseAttributeValue> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.List = result.Data;
                    }
                });
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial"));
            }
            return(View());
        }
        public async Task <ActionResult> Delete(string name)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
            {
                result = await client.DeleteAsync(name);

                if (result.Code == 0)
                {
                    result.Message = string.Format(StringResource.BaseAttributeCategory_Delete_Success
                                                   , name);
                }
                return(Json(result));
            }
        }
        //
        // GET: /BaseData/BaseAttributeCategory/
        public async Task <ActionResult> Index()
        {
            using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <BaseAttributeCategory> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }

            return(View(new BaseAttributeCategoryQueryViewModel()));
        }
        public async Task <ActionResult> SaveModify(BaseAttributeCategoryViewModel model)
        {
            using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
            {
                MethodReturnResult <BaseAttributeCategory> result = await client.GetAsync(model.Name);

                if (result.Code == 0)
                {
                    result.Data.Description = model.Description;
                    result.Data.Editor      = User.Identity.Name;
                    result.Data.EditTime    = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(StringResource.BaseAttributeCategory_SaveModify_Success
                                                    , model.Name);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
        public async Task <ActionResult> Save(BaseAttributeCategoryViewModel model)
        {
            using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
            {
                BaseAttributeCategory obj = new BaseAttributeCategory()
                {
                    Key         = model.Name,
                    Description = model.Description,
                    Editor      = User.Identity.Name,
                    EditTime    = DateTime.Now,
                    CreateTime  = DateTime.Now,
                    Creator     = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(StringResource.BaseAttributeCategory_Save_Success
                                                , model.Name);
                }
                return(Json(rst));
            }
        }
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <BaseAttributeCategory> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Ejemplo n.º 9
0
        //
        // GET: /BaseData/BaseAttribute/
        public async Task <ActionResult> Index(string categoryName)
        {
            using (BaseAttributeCategoryServiceClient client = new BaseAttributeCategoryServiceClient())
            {
                MethodReturnResult <BaseAttributeCategory> result = await client.GetAsync(categoryName ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "BaseAttributeCategory"));
                }
                ViewBag.BaseAttributeCategory = result.Data;
            }
            using (BaseAttributeServiceClient client = new BaseAttributeServiceClient())
            {
                await Task.Run(() =>
                {
                    string where     = string.Format("Key.CategoryName='{0}'", categoryName);
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key.CategoryName,Order",
                        Where   = where
                    };
                    MethodReturnResult <IList <BaseAttribute> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }

            return(View(new BaseAttributeQueryViewModel()
            {
                CategoryName = categoryName
            }));
        }