Exemplo n.º 1
0
        public ActionResult AddGoods(int?id)
        {
            int          pid   = id ?? 0;
            ProductModel model = new ProductModel();

            ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;

            bindOptions.BindProductPicsCount = 0;
            bindOptions.ProductBindType      = ProductBindType.Author | ProductBindType.Pics;

            if (pid > 0)
            {
                ProductServiceClient        client  = new ProductServiceClient();
                AdvancedResult <ProProduct> product = client.GetBBInfo(pid);
                if (product.Error == DataStructure.AppError.ERROR_SUCCESS)
                {
                    model.Bind(product.Data, bindOptions);
                }
                foreach (var item in model.Pics)
                {
                    item.DisplaySeting(126, 126);
                }
            }
            else
            {
                model        = new ProductModel();
                model.IsWash = true;
            }

            ViewBag.ProductJson = JsonHelper.Serialize(model);

            return(View("~/Views/User/AddGoods.cshtml", model));
        }
Exemplo n.º 2
0
        private AdvancedResult <List <ProductModel> > GetGoods(int pageIndex, int pageSize, ItemType itemType, ItemSort itemSort, PriceRange bbRange, SexType sexType, int age)
        {
            ProductServiceClient client = new ProductServiceClient();
            AdvancedResult <PageEntity <ProProduct> > response = client.LoadBBList(itemType, itemSort, bbRange, sexType, age, pageSize, pageIndex);

            List <ProductModel> items = new List <ProductModel>();

            if (response.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                response.Data.Items = response.Data.Items ?? new List <ProProduct>();

                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.ReplyCount | ProductBindType.Pics;
                bindOptions.BindProductPicsCount = 1;

                foreach (var p in response.Data.Items)
                {
                    items.Add(new ProductModel().Bind(p, bindOptions));
                }
            }
            AdvancedResult <List <ProductModel> > result = new AdvancedResult <List <ProductModel> >();

            result.Error        = response.Error;
            result.ErrorMessage = response.ErrorMessage;
            result.ExMessage    = response.ExMessage;
            result.Data         = items;
            return(result);
        }
Exemplo n.º 3
0
        public JsonResult GetReplys(int pid)
        {
            int pageIndex = 0;
            int pageSize  = 10;

            int.TryParse(Request["page"], out pageIndex);
            ReplyServiceClient client = new ReplyServiceClient();
            AdvancedResult <PageEntity <GenReply> > response = client.LoadReplyListByBBPostID(pid, pageIndex, pageSize);
            IList <ReplyModel> models = new List <ReplyModel>();
            string             paging = string.Empty;
            int count = 0;

            if (response.Error == AppError.ERROR_SUCCESS)
            {
                count  = response.Data.RecordsCount;
                paging = HtmlFormatHelper.GeneratePagingHtml(response.Data.PageIndex, response.Data.PageSize, response.Data.RecordsCount, "javascript:void(LoadComments({0}))", "下一页", "上一页", null, null, null);

                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.BindReplyCount    = 0;
                bindOptions.BindRefReplyCount = 1;
                bindOptions.ReplayBindType    = ReplyBindType.Author | ReplyBindType.RefReply;


                models = ReplyModel.BindList(response.Data.Items, bindOptions);
            }
            foreach (ReplyModel r in models)
            {
                if (r.Author != null && r.Author.HeadPic != null)
                {
                    r.Author.HeadPic.DisplaySeting(50, 50);
                }
            }
            return(Json(new { data = models, paging = paging, count = count }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult Goods(int?id)
        {
            ProductServiceClient client = new ProductServiceClient();

            int page = id ?? 0;

            AdvancedResult <PageEntity <ProProduct> > products = client.SearchBBPostList(CurrentToken, page, 6);
            List <ProductModel> items = new List <ProductModel>();

            ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;

            bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.ReplyCount | ProductBindType.Pics;
            bindOptions.BindProductPicsCount = 1;

            if (products.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                products.Data.Items = products.Data.Items ?? new List <ProProduct>();
                ViewBag.Paging      = BabyPlan.Common.HtmlFormatHelper.GeneratePagingHtml(page, 6, products.Data.RecordsCount, Url.Action("Goods", "User") + "/{0}");
                foreach (var p in products.Data.Items)
                {
                    items.Add(new ProductModel().Bind(p, bindOptions));
                }
            }
            return(View("~/Views/User/Goods.cshtml", items));
        }
Exemplo n.º 5
0
        public JsonResult AjaxLogin()
        {
            string username    = Request["username"];
            string password    = Request["password"];
            string getUserInfo = Request["userinfo"];
            AdUser user        = null;
            AdvancedResult <string> response = Login(username, password, ref user);

            if (string.IsNullOrEmpty(getUserInfo))
            {
                return(this.Json(response));
            }
            else
            {
                AdvancedResult <UserModel> userResponse = new AdvancedResult <UserModel>();
                if (response.Error != AppError.ERROR_SUCCESS)
                {
                    return(this.Json(response));
                }
                else
                {
                    userResponse.Error        = response.Error;
                    userResponse.ErrorMessage = response.ErrorMessage;
                    userResponse.ExMessage    = response.ExMessage;
                    ViewModelBindOption bindoption = new ViewModelBindOption();
                    userResponse.Data = new UserModel().Bind(user, bindoption);
                }
                return(this.Json(userResponse));
            }
        }
Exemplo n.º 6
0
        public ActionResult Detail(int id)
        {
            ViewBag.ItemId = id;
            ProductServiceClient client = new ProductServiceClient();
            AdvancedResult <List <ProProduct> > response = client.LoadInterestingBB(CurrentToken);

            List <ProductModel> interestings = new List <ProductModel>();

            if (response.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                response.Data = response.Data ?? new List <ProProduct>();
                response.Data = response.Data.Take(4).ToList();

                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.ProductBindType = bindOptions.ProductBindType | ProductBindType.Pics;

                foreach (var p in response.Data)
                {
                    interestings.Add(new ProductModel().Bind(p, bindOptions));
                }
            }

            ProductModel productModel           = new ProductModel();
            AdvancedResult <ProProduct> product = client.GetBBInfo(id);

            if (product.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.BindProductPicsCount = 0;
                bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.Author | ProductBindType.Pics;
                bindOptions.UserBindType         = bindOptions.UserBindType | UserBindType.PubProductCount;
                productModel.Bind(product.Data, bindOptions);

                client.SetBBPostViewNum(product.Data.Pid);
            }

            ViewBag.Product   = productModel;
            ViewBag.Interests = interestings;

            return(View("~/Views/Trade/Detail.cshtml"));
        }
Exemplo n.º 7
0
        public JsonResult GetGoodsDetail()
        {
            int id = 0;

            int.TryParse(Request["id"], out id);
            ProductServiceClient          client     = new ProductServiceClient();
            AdvancedResult <ProProduct>   dbresponse = client.GetBBInfo(id);
            AdvancedResult <ProductModel> response   = new AdvancedResult <ProductModel>();

            response.Error        = dbresponse.Error;
            response.ErrorMessage = dbresponse.ErrorMessage;
            response.ExMessage    = dbresponse.ExMessage;
            if (dbresponse.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                //bindOptions.ProductItemBindType = bindOptions.ProductItemBindType | ProductItemBindType.Product;
                bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.Author | ProductBindType.ReplyCount | ProductBindType.Pics;
                bindOptions.BindProductPicsCount = 0;
                response.Data = new ProductModel().Bind(dbresponse.Data, bindOptions);
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        //
        // GET: /User/
        public ActionResult Index()
        {
            ProductServiceClient client = new ProductServiceClient();
            AdvancedResult <List <ProProduct> > response = client.LoadInterestingBB(CurrentToken);

            List <ProductModel> items = new List <ProductModel>();

            if (response.Error == DataStructure.AppError.ERROR_SUCCESS)
            {
                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.Pics;
                bindOptions.ProductBindType      = bindOptions.ProductBindType | ProductBindType.ReplyCount;
                bindOptions.BindProductPicsCount = 1;

                response.Data = response.Data ?? new List <ProProduct>();
                foreach (var p in response.Data)
                {
                    items.Add(new ProductModel().Bind(p, bindOptions));
                }
            }
            return(View("~/Views/User/Index.cshtml", items));
        }
Exemplo n.º 9
0
        public ActionResult Info()
        {
            ReplyServiceClient client = new ReplyServiceClient();
            AdvancedResult <PageEntity <GenReply> > replys = client.LoadMyBBReplyList(CurrentToken, 0, 9);
            IList <ReplyModel> models = new List <ReplyModel>();

            if (replys.Error == AppError.ERROR_SUCCESS)
            {
                ViewModelBindOption bindOptions = ViewModelBindOption.DefalutBindOption;
                bindOptions.BindReplyCount  = 0;
                bindOptions.ProductBindType = bindOptions.ProductBindType | ProductBindType.ReplyCount;
                bindOptions.ReplayBindType  = ReplyBindType.Author | ReplyBindType.Product;

                models = ReplyModel.BindList(replys.Data.Items, bindOptions);
            }
            foreach (ReplyModel r in models)
            {
                if (r.Author != null && r.Author.HeadPic != null)
                {
                    r.Author.HeadPic.DisplaySeting(50, 50);
                }
            }
            return(View("~/Views/User/Info.cshtml", models));
        }
Exemplo n.º 10
0
        public JsonResult AjaxRegister()
        {
            string username    = Request["username"];
            string password    = Request["password"];
            string sex         = Request["sex"];
            string getUserInfo = Request["userinfo"];

            AdvancedResult <string> response = new AdvancedResult <string>();

            if (string.IsNullOrEmpty(username) || username.Length < 4 || username.Length > 16)
            {
                response.Error     = AppError.ERROR_FAILED;
                response.ExMessage = "用户名长度不合法!";
                return(Json(response));
            }
            if (string.IsNullOrEmpty(password) || password.Length < 6 || password.Length > 18)
            {
                response.Error     = AppError.ERROR_FAILED;
                response.ExMessage = "密码长度不合法!";
                return(Json(response));
            }
            AdUser user = null;

            try
            {
                UserServiceClient client = new UserServiceClient();
                response = client.Register(username, SecurityHelper.MD5(password));
                if (response.Error == AppError.ERROR_SUCCESS)
                {
                    //AdvancedResult<AdUser> getResponse = client.GetUserInfo(response.Data);
                    //if (getResponse.Error == AppError.ERROR_SUCCESS)
                    //{
                    //    SexType sexType = SexType.Ignore;
                    //    Enum.TryParse<SexType>(sex, out sexType);
                    //    getResponse.Data.Sex = sexType;
                    //    client.EditeUserInfo();
                    //}
                    AdvancedResult <string> regLogin = Login(username, password, ref user);
                    if (regLogin.ExMessage != null && regLogin.ExMessage.Length > 0)
                    {
                        response.ExMessage = string.Format("注册成功!,{0}", regLogin.ExMessage);
                    }
                }
                client.Close();
                client = null;
            }
            catch (Exception ex)
            {
                response.Error     = AppError.ERROR_FAILED;
                response.ExMessage = ex.Message;
            }
            if (string.IsNullOrEmpty(getUserInfo))
            {
                return(this.Json(response));
            }
            else
            {
                AdvancedResult <UserModel> userResponse = new AdvancedResult <UserModel>();
                if (response.Error != AppError.ERROR_SUCCESS)
                {
                    return(this.Json(response));
                }
                else
                {
                    userResponse.Error        = response.Error;
                    userResponse.ErrorMessage = response.ErrorMessage;
                    userResponse.ExMessage    = response.ExMessage;
                    ViewModelBindOption bindoption = new ViewModelBindOption();
                    userResponse.Data = new UserModel().Bind(user, bindoption);
                }
                return(this.Json(userResponse));
            }
        }