コード例 #1
0
ファイル: AgentController.cs プロジェクト: 21ki/kuanmai
        public ActionResult EditCustomerActivity(int activityId, int customerId)
        {
            ActivityManagement    activityMgr = new ActivityManagement(User.Identity.GetUserId <int>());
            List <BActivity>      activities  = activityMgr.FindActivities(activityId, User.Identity.GetUserId <int>(), customerId, out total, true, 1, 1);
            CustomerActivityModel model       = new CustomerActivityModel();

            if (activities.Count == 1)
            {
                BActivity activity = activities[0];
                model.Id          = activity.Activity.Id;
                model.CustomerId  = customerId;
                model.Description = activity.Activity.Description;
                model.Enable      = activity.Activity.Enabled;
                model.ExpiredTime = activity.Activity.ExpiredTime > 0 ? DateTimeUtil.ConvertToDateTime(activity.Activity.ExpiredTime).ToString("yyyy-M-dd") : "";
                model.Name        = activity.Activity.Name;
                model.ScanType    = activity.Activity.ScanType;
                model.StartTime   = activity.Activity.ExpiredTime > 0 ? DateTimeUtil.ConvertToDateTime(activity.Activity.StartedTime).ToString("yyyy-M-dd") : "";
            }
            else
            {
                ViewBag.Message = "不能修改不属于自己客户的活动";
                return(View("Error"));
            }

            List <DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList();

            ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id = st.Id, Name = st.Value }, "Id", "Name");
            return(View("CreateCustomerActivity", model));
        }
コード例 #2
0
ファイル: AgentController.cs プロジェクト: 21ki/kuanmai
        public ActionResult CreateCustomerActivity(int customerId)
        {
            CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>());
            List <BCustomer>   customers   = customerMgr.FindCustomers(User.Identity.GetUserId <int>(), customerId, out total);

            if (customers.Count == 0)
            {
                ViewBag.Message = string.Format("编号为:{0}的客户不是你的客户");
                return(View("Error"));
            }
            AgentManagement    agentMgr = new AgentManagement(customerMgr.CurrentLoginUser);
            List <BAgentRoute> routes   = agentMgr.FindTaocans(0, true);

            ViewBag.Customer = customers[0];
            ViewBag.Routes   = new SelectList((from r in routes select new { Id = r.Route.Id, Name = r.Taocan.Taocan2.Name + " - " + (r.Taocan.Taocan.Sale_price * r.Route.Discount).ToString("0.00") + "元" }), "Id", "Name");
            List <DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList();

            ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id = st.Id, Name = st.Value }, "Id", "Name");
            CustomerActivityModel model = new CustomerActivityModel()
            {
                Id = 0, CustomerId = customerId, Enable = true
            };

            return(View(model));
        }
コード例 #3
0
ファイル: AgentController.cs プロジェクト: 21ki/kuanmai
        public ActionResult CreateCustomerActivity(CustomerActivityModel model)
        {
            if (ModelState.IsValid)
            {
                ActivityManagement   activityMgr = new ActivityManagement(User.Identity.GetUserId <int>());
                Marketing_Activities activity    = new Marketing_Activities()
                {
                    AgentId     = User.Identity.GetUserId <int>(),
                    CreatedTime = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now),
                    CustomerId  = model.CustomerId,
                    Description = model.Description,
                    ScanType    = model.ScanType,
                    Enabled     = model.Enable,
                    Name        = model.Name,
                    Id          = model.Id
                };

                if (model.Id == 0)
                {
                    activity = activityMgr.CreateNewActivity(activity);
                    if (activity.Id > 0)
                    {
                        return(Redirect("/Agent/CustomerAcivities?customerId=" + model.CustomerId));
                    }
                }
                else
                {
                    activityMgr.UpdateActivity(activity);
                    return(Redirect("/Agent/CustomerAcivities?customerId=" + model.CustomerId));
                }
            }
            List <DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList();

            ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id = st.Id, Name = st.Value }, "Id", "Name");
            return(View(model));
        }