/// <summary>
        /// Gets the customer comment list
        /// </summary>
        /// <param name="param"></param>
        /// <returns>Customer comment List</returns>
        public ActionResult CustomerCommentList(MODEL.jQueryDataTableParamModel param)
        {
            try
            {
                List <Company>   companyList   = Session.GetUserAssociatedCompanyList();
                List <CompanyVO> companyVOList = new List <CompanyVO>();
                foreach (var item in companyList)
                {
                    //companyVOList.Add(new CompanyVO(item));
                    companyVOList.Add(item.Transpose());
                }

                CustomerCommentService       customerCommentService = new CustomerCommentService();
                List <MODEL.CustomerComment> customerCommentList    = new List <CustomerComment>();

                List <CustomerCommentVO> customerCommentVOList = customerCommentService.GetCustomerCommentList(companyVOList);

                foreach (var item in customerCommentVOList)
                {
                    customerCommentList.Add(new MODEL.CustomerComment(item));
                }

                //get the field on with sorting needs to happen and set the
                //ordering function/delegate accordingly.
                int sortColumnIndex  = Convert.ToInt32(Request["iSortCol_0"]);
                var orderingFunction = GetCustomerCommentOrderingFunction(sortColumnIndex);

                var result = GetFilteredObjects(param, customerCommentList, orderingFunction);
                return(result);
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
        /// <summary>
        /// Gets the Customer comment list
        /// </summary>
        /// <param name="companyId">company Id</param>
        /// <param name="invoiceCustomerId">invoiceCustomer Id</param>
        /// <returns>Customer commnet list</returns>
        private string GetCustomerComment(int companyId, int invoiceCustomerId)
        {
            MODEL.Contract contract = new MODEL.Contract();

            CustomerCommentService customerCommentService = new CustomerCommentService();
            CustomerCommentVO      customerCommentVO      = customerCommentService.GetCustomerCommentByCompanyAndCutomer(companyId, invoiceCustomerId);

            if (customerCommentVO != null)
            {
                contract.CustomerComment = customerCommentVO.CustomerComment;
            }

            return(contract.CustomerComment);
        }
        /// <summary>
        /// Delete the Customer comment(s)
        /// </summary>
        /// <param name="Ids">Ids of customerComment to be deleted</param>
        public ActionResult CustomerCommentDelete(List <int> ids)
        {
            try
            {
                //Get User Id
                int?userId = Session.GetUserId();

                CustomerCommentService customerCommentService = new CustomerCommentService();
                customerCommentService.DeleteCustomerComment(ids, userId);
                return(new HttpStatusCodeResult(200));
            }
            catch (Exception e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
        public ActionResult CustomerCommentListPage(FlagEnum hasDeal, string beginTime, string endTime, int pageIndex = 1, int pageSize = 10)
        {
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }
            pageSize = pageSize < 1 ? PageSize : pageSize;
            var beginDateTime = DataTypeConvertHelper.ToDateTime(beginTime, new DateTime(1900, 1, 1));
            var endDateTime   = DataTypeConvertHelper.ToDateTime(endTime, new DateTime(1900, 1, 1));
            var server        = new CustomerCommentService();
            var dataList      = server.GetList(beginDateTime, endDateTime, hasDeal, pageIndex, pageSize, out var count);
            var resultMode    = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Success,
                Message    = "响应成功",
                Data       = new { count, dataList }
            };

            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Save the customer comment
        /// </summary>
        /// <param name="model">model object</param>
        /// <returns></returns>
        public ActionResult CustomerCommentSave(MODEL.CustomerComment model)
        {
            try
            {
                bool ismodelValid = ModelState.IsValid;
                if (!ismodelValid)
                {
                    ismodelValid = IsModelValidForMultilineTextbox("Comment", model.Comment, 220);

                    if (ismodelValid)
                    {
                        model.Comment = model.Comment.Replace("\r\n", "\n");
                    }
                }

                if (ismodelValid)
                {
                    //Get user id
                    int?userId = Session.GetUserId();
                    CustomerCommentService customerCommentService = new CustomerCommentService();
                    //CustomerCommentVO customerCommentVO = new CustomerCommentVO(model, userId);

                    CustomerCommentVO customerCommentVO = model.Transpose(userId);

                    customerCommentService.SaveCustomerComment(customerCommentVO);
                    return(new HttpStatusCodeResult(200));
                }
                else
                {
                    throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.CUSTOMERCOMMENT));
                }
            }
            catch (ApplicationException e)
            {
                return(new HttpStatusCodeAndErrorResult(500, e.Message));
            }
        }
        /// <summary>
        /// Edit customer comment
        /// </summary>
        /// <param name="id">The customer comment id</param>
        /// <returns>Customer comment details</returns>
        public ActionResult CustomerCommentEdit(int id)
        {
            MODEL.CustomerComment customercomment = new CustomerComment();
            try
            {
                CustomerCommentService customerCommentService = new CustomerCommentService();

                //Get Customercomment details
                CustomerCommentVO customerCommentVO = customerCommentService.GetCustomerCommentById(id);
                if (customerCommentVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.CUSTOMERCOMMENT));
                }
                else
                {
                    customercomment = new CustomerComment(customerCommentVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("CustomerCommentDetails", customercomment));
        }
        public ActionResult DealResultModels(long id, string dealResult)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Success,
                Message    = "响应成功"
            };

            if (id < 1)
            {
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            var server = new CustomerCommentService();

            try
            {
                server.DealComment(id, dealResult);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
            }
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DelResourceModels(List <long> ids)
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Success,
                Message    = "响应成功"
            };

            if (ids == null || ids.Count < 1)
            {
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            var server = new CustomerCommentService();

            try
            {
                server.DelModel(ids);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
            }
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }
示例#9
0
        /// <summary>
        /// 添加留言信息
        /// </summary>
        /// <returns></returns>
        public ActionResult AddCommentInfo()
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Fail,
                Message    = "响应成功"
            };
            var checkcode = System.Web.HttpContext.Current.GetStringFromParameters("checkcode");

            if (string.IsNullOrEmpty(checkcode) || string.IsNullOrEmpty(Session["ValidateCode"]?.ToString()))
            {
                resultMode.Message = "验证码必填";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            var oldCode = Session["ValidateCode"];

            Session["ValidateCode"] = null;
            if (!oldCode.Equals(checkcode))
            {
                resultMode.Message = "验证码必填";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            var content       = System.Web.HttpContext.Current.GetStringFromParameters("content");
            var createTime    = DateTime.Now;
            var customerEmail = System.Web.HttpContext.Current.GetStringFromParameters("email");
            var customerName  = System.Web.HttpContext.Current.GetStringFromParameters("username");
            var customerPhone = System.Web.HttpContext.Current.GetStringFromParameters("tel");

            var    fw       = new FilterWord();
            string str      = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            var    filePath = AppConfigurationHelper.GetString("SensitiveFilePath");

            fw.DictionaryPath = str + filePath;
            fw.SourctText     = content;
            content           = fw.Filter('*');
            if (string.IsNullOrEmpty(content))
            {
                resultMode.Message = "留言内容不能为空";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            fw.SourctText = customerEmail;
            customerEmail = fw.Filter('*');
            if (string.IsNullOrEmpty(customerEmail) || !RegExp.IsEmail(customerEmail))
            {
                resultMode.Message = "邮箱内容错误";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            fw.SourctText = customerName;
            customerName  = fw.Filter('*');
            if (string.IsNullOrEmpty(customerName))
            {
                resultMode.Message = "姓名内容错误";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            fw.SourctText = customerPhone;
            customerPhone = fw.Filter('*');
            if (string.IsNullOrEmpty(customerPhone) || !RegExp.IsMobileNo(customerPhone))
            {
                resultMode.Message = "电话内容错误";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            var commentModel = new CustomercommentModel {
                Content = content, CreateTime = createTime, CustomerName = customerName, CustomerEmail = customerEmail, CustomerPhone = customerPhone, IsDel = FlagEnum.HadZore.GetHashCode(), HasDeal = FlagEnum.HadZore
            };
            var server = new CustomerCommentService();

            try
            {
                server.SaveModel(commentModel);
                resultMode.Message    = "处理成功";
                resultMode.ResultCode = ResponceCodeEnum.Success;
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
                resultMode.Message = "系统异常";
            }
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }