Пример #1
0
 /// <summary>
 /// 通过ID获取文章类型
 /// </summary>
 /// <param name="Id"></param>
 /// <returns></returns>
 public ArticleType GetArticleTypeById(int Id)
 {
     ArticleType model = new ArticleType();
     DataTable dt = dataBase.GetOnlyById4MySql(Id.ToString(), tableName).Tables[0];
     if (dt != null)
     {
         return FillData.FillDataToEntity(model, dt);
     }
     else
     {
         return null;
     }
 }
Пример #2
0
 /// <summary>
 /// 添加文章分类
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Insert(ArticleType model)
 {
     if (model != null)
     {
         string sql = FillData.AppendSqlToInsert(model);
         MySqlCommand cmd = new MySqlCommand(sql, DataBase.GetOpenConn4MySql());
         MySqlParameter[] para = FillData.AppendParas(model);
         cmd.Parameters.AddRange(para);
         int result = cmd.ExecuteNonQuery();
         if (result > 0)
         {
             return true;
         }
         return false;
     }
     else
     {
         return false;
     }
 }
        public ActionResult Insert(string typeName, string mark)
        {
            try
            {
                ArticleType model = new ArticleType
                {
                    Id = Guid.NewGuid().ToString("N"),
                    TypeName = typeName,
                    Mark = mark,
                    CreateUser = CUR_USER.UserName,
                    CreateTime = DateTime.Now
                };
                if (_IArticleTypeService.Insert(model))
                {
                    return AlertMsg("添加成功!", Url.Action("AddArticle", "Home"));
                }
                else
                {
                    return AlertMsgAndJs("添加失败!", "history.go(-1);");
                }

            }
            catch (Exception e)
            {
                string error = string.Format("发生异常页: {0};异常信息: {1}", Request.Url, e.Message);
                log.Error(error);
                _ISysLogService.Insert(new SysLog()
                {
                    Location = e.Source.ToString(),
                    Content = "e.StackTrace:" + e.StackTrace + ",e.Data:" + e.Data,
                    Error = e.Message,
                    CreateUser = Session["UserName"] != null ? Session["UserName"].ToString() : "无用户名",
                    RemoteHost = Request.UserHostAddress + ":" + Request.UserHostName,
                    RequestData = Request.Params.ToString(),
                    Browser = Request.Browser.Browser + Request.Browser.Version,
                    ActionCode = Request.RawUrl,
                });
                return AlertMsgAndJs("添加失败!", "history.go(-1);");
            }
        }
Пример #4
0
 public int Update(ArticleType model)
 {
     throw new NotImplementedException();
 }
Пример #5
0
 public bool Insert(ArticleType model)
 {
     return _IArticleTypeDao.Insert(model);
 }