Beispiel #1
0
        public ActionResult Index(FeedbackInfo model,FormCollection fc) {
            
            /*
             * 设置_CommmonLayout.cshtml中的变量
             */

            ViewBag.RootCategoryInfo = ViewBag.CurrentCategoryInfo = CategoryService.Get(GeneralConfig.FeedbackRootId);

            bool errors = false;
            if(string.IsNullOrEmpty(model.Title)){
                errors = true;
                ModelState.AddModelError("Title", "请输入投诉(建议)标题");
            }
            if(string.IsNullOrEmpty(model.Content)){
                errors = true;
                ModelState.AddModelError("Content", "请输入投诉(建议)内容");
            }

            if(ModelState.IsValid && !errors){

                //过滤掉内容HTML
                model.Content = Goodspeed.Library.Char.HtmlHelper.RemoveHtml(model.Content);

                int id = FeedbackService.Create(model).Id;
                ViewBag.Status = false;
                if(id>0){
                    ViewBag.Status = true;
                }
            }

            return View();
        }
Beispiel #2
0
 /// <summary>
 /// 添加或编辑
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static FeedbackInfo Create(FeedbackInfo model) { 
     if(model.Id == 0){
         int id = FeedbackManage.Insert(model);
         model.Id = id;
     }
     return model;
 }
Beispiel #3
0
 /// <summary>
 /// 插入
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Insert(FeedbackInfo model) {
     string strSQL = "INSERT INTO Feedback(Title,Content,[Address],Contact,Email,Phone,Fax,CreateDateTime,IsDeleted) VALUES(@Title,@Content,@Address,@Contact,@Email,@Phone,@Fax,GETDATE(),0);SELECT @@IDENTITY;";
     SqlParameter[] param = {
                             new SqlParameter("Title",SqlDbType.NVarChar),
                             new SqlParameter("Content",SqlDbType.NVarChar),
                             new SqlParameter("Address",SqlDbType.NVarChar),
                             new SqlParameter("Contact",SqlDbType.NVarChar),
                             new SqlParameter("Email",SqlDbType.NVarChar),
                             new SqlParameter("Phone",SqlDbType.NVarChar),
                             new SqlParameter("Fax",SqlDbType.NVarChar),
                          };
     param[0].Value = model.Title ?? string.Empty;
     param[1].Value = model.Content ?? string.Empty;
     param[2].Value = model.Address ?? string.Empty;
     param[3].Value = model.Contact ?? string.Empty;
     param[4].Value = model.Email ?? string.Empty;
     param[5].Value = model.Phone ?? string.Empty;
     param[6].Value = model.Fax ?? string.Empty;
     return Convert.ToInt32(Goodspeed.Library.Data.SQLPlus.ExecuteScalar(CommandType.Text,strSQL,param));
 }