Пример #1
0
        public ActionResult Feedback(FormCollection fc)
        {
            var    companyInfo    = ViewBag.CompanyInfo;
            string cbType         = fc["cbType"];
            string txtNeed        = fc["txtNeed"];
            string txtRealName    = fc["txtRealName"];
            string txtCompanyName = fc["txtCompanyName"];
            string txtPhone       = fc["txtPhone"];
            string txtEmail       = fc["txtEmail"];

            bool errors = false;

            if (string.IsNullOrEmpty(cbType))
            {
                errors = true;
                ModelState.AddModelError("TYPE", "请选择您的需求");
            }
            if (string.IsNullOrEmpty(txtNeed))
            {
                errors = true;
                ModelState.AddModelError("NEED", "请输入您的详细需求");
            }
            if (string.IsNullOrEmpty(txtRealName))
            {
                errors = true;
                ModelState.AddModelError("REALNAME", "请输入您的姓名");
            }
            if (string.IsNullOrEmpty(txtCompanyName))
            {
                errors = true;
                ModelState.AddModelError("COMPANYNAME", "请输入您的公司");
            }
            if (string.IsNullOrEmpty(txtPhone))
            {
                errors = true;
                ModelState.AddModelError("PHONE", "请输入您的电话");
            }
            if (string.IsNullOrEmpty(txtEmail))
            {
                errors = true;
                ModelState.AddModelError("EMAIL", "请输入您的邮件");
            }
            if (!errors && ModelState.IsValid)
            {
                //添加反馈
                CompanyFeedbackService.Insert(new CompanyFeedbackInfo()
                {
                    CompanyName  = txtCompanyName,
                    RealName     = txtRealName,
                    Type         = cbType,
                    Content      = txtNeed,
                    Email        = txtEmail,
                    ForCompanyId = companyInfo.CompanyId,
                    UserId       = 0,
                    Phone        = txtPhone,
                    IP           = CECRequest.GetIP()
                });

                ViewBag.Msg = "Success";
            }

            var frontFeedbackList = CompanyFeedbackService.FrontList(companyInfo.CompanyId, 1, 10);

            ViewBag.FrontFeedbackList = frontFeedbackList;
            return(View());
        }