Example #1
0
 public ActionResult Add()
 {
     if (!CurrentWeChatUser.IsUserLoggedIn)
     {
         return Redirect("/wechat/account/login");
     }
     DemandModel model = new DemandModel();
     model.Provinces = cityService.GetProvinces(true);
     return View(model);
 }
Example #2
0
        /// <summary>
        /// 我的购买记录
        /// </summary>
        /// <returns></returns>
        public ActionResult MyPaidDemand(int page = 1)
        {
            DemandModel model = new DemandModel();

            model.PageIndex = page;//当前页数
            model.PageSize = 10;//每页显示多少条
            model.PageStep = 5;//每页显示多少页码
            model.ActionName = "MyPaidDemand";

            int allCount = 0;
            model.PaidDemandOrders = orderService.GetWeChatUserPaidDemands(CurrentWeChatUser.OpenId, model.PageSize, model.PageIndex, out allCount);

            //分页
            if (model.PaidDemandOrders != null && model.PaidDemandOrders.Count > 0)
            {
                model.AllCount = allCount;//总条数
                if (model.AllCount % model.PageSize == 0)
                {
                    model.PageCount = model.AllCount / model.PageSize;
                }
                else
                {
                    model.PageCount = model.AllCount / model.PageSize + 1;
                }
            }

            return View(model);
        }
Example #3
0
        public ActionResult Show(string id)
        {
            DemandModel model = new DemandModel();

            int tempId = 0;
            if (!string.IsNullOrEmpty(id))
            {
                Int32.TryParse(id, out tempId);
            }

            if (tempId != 0)
            {
                bool hasWeChatUserBoughtForDemand = false;
                var demand = demandService.GetDemandById(tempId);

                if (demand != null)
                {
                    demand.ContentText = FilterHelper.Filter(FilterLevel.PhoneAndEmail, demand.ContentText, CommonService.ReplacementForContactInfo);
                    demand.ContentStyle = FilterHelper.Filter(FilterLevel.PhoneAndEmail, demand.ContentStyle, CommonService.ReplacementForContactInfo);
                    demand.Description = FilterHelper.Filter(FilterLevel.PhoneAndEmail, demand.Description, CommonService.ReplacementForContactInfo);
                    demand.Title = FilterHelper.Filter(FilterLevel.PhoneAndEmail, demand.Title, CommonService.ReplacementForContactInfo);

                    // 如果是自己发布的需求,无需购买即可查看
                    var isPostedByMyself = (demand.UserId == CurrentWeChatUser.UserId);
                    hasWeChatUserBoughtForDemand = isPostedByMyself || demandService.HasWeChatUserBoughtForDemand(CurrentWeChatUser.OpenId, demand.Id);

                    // 查询报价记录
                    if (isPostedByMyself)
                    {
                        var quotes = quoteService.GetAllDemandQuotesForOneDemand(demand.Id);
                        if (quotes.HasItem())
                        {
                            demand.QuoteEntities.AddRange(quotes);
                        }
                    }

                    if (!hasWeChatUserBoughtForDemand)
                    {
                        demand.Phone = "未购买查看权限";
                        demand.QQWeixin = "未购买查看权限";
                        demand.Email = "未购买查看权限";
                        demand.Address = "未购买查看权限";
                    }
                }

                model.HasCurrentWeChatUserBought = hasWeChatUserBoughtForDemand;
                model.Demand = demand;
            }

            if (model.Demand == null)
            {
                model.Demand = new Demand();
                model.Demand.Title = "该需求不存在或已被删除";
                model.Demand.StartTime = DateTime.Now;
                model.Demand.EndTime = DateTime.Now;
            }

            ViewData["BuyDemandFee"] = BuyDemandFee.ToString();

            return View(model);
        }
Example #4
0
        /// <summary>
        /// 我发布的需求记录
        /// </summary>
        /// <returns></returns>
        public ActionResult MyDemands(string page)
        {
            if (!CurrentWeChatUser.IsUserLoggedIn)
            {
                return Redirect("/wechat/account/login");
            }

            DemandModel model = new DemandModel();
            model.ActionName = "MyDemands";

            //页码,总数重置
            int pageIndex = 1;
            if (!string.IsNullOrEmpty(page))
            {
                Int32.TryParse(page, out pageIndex);
            }
            int allCount = 0;
            model.Demands = demandService.GetDemandsByUserId(CurrentWeChatUser.UserId.Value, 20, pageIndex, out allCount);//每页显示20条
            //分页
            if (model.Demands != null && model.Demands.Count > 0)
            {
                model.PageIndex = pageIndex;//当前页数
                model.PageSize = 20;//每页显示多少条
                model.PageStep = 10;//每页显示多少页码
                model.AllCount = allCount;//总条数
                if (model.AllCount % model.PageSize == 0)
                {
                    model.PageCount = model.AllCount / model.PageSize;
                }
                else
                {
                    model.PageCount = model.AllCount / model.PageSize + 1;
                }
            }

            return View(model);
        }
Example #5
0
        public ActionResult Index(string page, string LastResourceType, string ResourceType, string ResourceTypeId, string area, string starttime, string endtime, string startbudget, string endbudget)
        {
            DemandModel model = new DemandModel();

            string city = string.Empty;
            if (!string.IsNullOrEmpty(CurrentCityId))
            {
                city = CurrentCityId;
            }
            int tempPage = 1;
            if (!string.IsNullOrEmpty(page))
            {
                Int32.TryParse(page, out tempPage);
            }

            // 每次更换需求列别需要重置需求类型选中的值
            if (string.IsNullOrEmpty(ResourceType))
            {
                ResourceTypeId = string.Empty;
            }
            if (!(LastResourceType ?? string.Empty).Equals(ResourceType, StringComparison.CurrentCultureIgnoreCase))
            {
                ResourceTypeId = string.Empty;
            }
            LastResourceType = ResourceType;

            //-------------------------------初始化页面参数(不含分页)-----------------------
            model.PageIndex = tempPage;
            model.LastResourceType = LastResourceType ?? string.Empty;
            model.ResourceType = ResourceType ?? string.Empty;
            model.ResourceTypeId = ResourceTypeId ?? string.Empty;
            model.City = city;
            model.Area = area ?? string.Empty;
            model.StartBudget = startbudget ?? string.Empty;
            model.EndBudget = endbudget ?? string.Empty;
            model.StartTime = starttime ?? string.Empty;
            model.EndTime = endtime ?? string.Empty;

            //-------------------------------初始化SQL查询参数-----------------------
            DemandParameters parameters = new DemandParameters();
            parameters.PageCount = 10;//每页显示10条 (与下面保持一致)
            parameters.PageIndex = tempPage;
            parameters.ResourceType = model.ResourceType;
            parameters.ResourceTypeId = model.ResourceTypeId;
            parameters.City = model.City;
            parameters.Area = model.Area;
            parameters.StartBudget = model.StartBudget;
            parameters.EndBudget = model.EndBudget;
            parameters.StartTime = model.StartTime;
            parameters.EndTime = model.EndTime;

            if (!string.IsNullOrEmpty(city))
            {
                model.Areas = cityService.GetAreasByCityId(city, true);
            }

            int allCount = 0;
            //需求分页列表,每页10条
            model.Demands = demandService.GetDemandsByParameters(parameters, out allCount);
            //分页
            if (model.Demands != null && model.Demands.Count > 0)
            {
                model.PageIndex = tempPage;//当前页数
                model.PageSize = 10;//每页显示多少条
                model.PageStep = 5;//每页显示多少页码
                model.AllCount = allCount;//总条数
                if (model.AllCount % model.PageSize == 0)
                {
                    model.PageCount = model.AllCount / model.PageSize;
                }
                else
                {
                    model.PageCount = model.AllCount / model.PageSize + 1;
                }
            }

            return View(model);
        }
Example #6
0
        public ActionResult Edit(int id)
        {
            if (!CurrentWeChatUser.IsUserLoggedIn)
            {
                return Redirect("/wechat/account/login");
            }
            DemandModel model = new DemandModel();

            model.Provinces = cityService.GetProvinces(true);//省

            if (id > 0)
            {
                model.Demand = demandService.GetDemandById(id);
                if (model.Demand != null)
                {
                    if (CurrentUser.UserId == model.Demand.UserId)
                    {
                        if (!string.IsNullOrEmpty(model.Demand.Province))
                        {
                            model.Cities = cityService.GetCitiesByProvinceId(model.Demand.Province, true);//市
                        }
                        if (!string.IsNullOrEmpty(model.Demand.City))
                        {
                            model.Areas = cityService.GetAreasByCityId(model.Demand.City, true);//区
                        }
                    }
                }
            }
            if (model.Demand == null)
            {
                model.Demand = new Demand();
            }

            return View(model);
        }
Example #7
0
        public ActionResult ViewAll(long ticks)
        {
            DemandModel model = new DemandModel();

            try
            {
                var subscription = subscriptionService.GetSubscription(CurrentWeChatUser.Id);
                if (subscription.IsNotNull())
                {
                    //var lastPushTime = new DateTime(ticks);
                    var lastPushTime = DateTime.Today;// 今日所有推荐

                    // Gets demands by user's subscription details.
                    var demands = demandService.SelectDemandsForWeChatPush(subscription.SubscriptionDetails, lastPushTime);

                    model.Demands = demands;
                }
            }

            catch (Exception ex)
            {
                LogService.LogWexin("查看所有推荐出错", ex.ToString());
            }

            if (!model.Demands.IsNotNull())
            {
                model.Demands = new List<Demand>();
            }

            return View(model);
        }
Example #8
0
        /// <summary>
        /// 我收到的需求报价列表
        /// </summary>
        /// <returns></returns>
        public ActionResult RecievedQuotes(int pageIndex = 1)
        {
            DemandModel model = new DemandModel();

            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            int totalCount = 0;
            var demands = quoteService.GetRecievedQuotes(CurrentWeChatUser.Id, 15, pageIndex, out totalCount);

            //分页
            if (demands != null && demands.Count > 0)
            {
                model.Demands = demands;

                model.PageIndex = pageIndex;//当前页数
                model.PageSize = 15;//每页显示多少条
                model.PageStep = 10;//每页显示多少页码
                model.AllCount = totalCount;//总条数
                if (model.AllCount % model.PageSize == 0)
                {
                    model.PageCount = model.AllCount / model.PageSize;
                }
                else
                {
                    model.PageCount = model.AllCount / model.PageSize + 1;
                }

                model.ActionName = "RecievedQuotes";
            }

            return View(model);
        }