示例#1
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public object GetFormJsonOILType(string keyValue)
        {
            int fId = ConvertVal.GetValInt(keyValue);
            var m   = _repository.IQueryableAsNoTracking <T_OILType>(p => p.F_ID == fId).FirstOrDefault();

            return(m);
        }
示例#2
0
 public object DeleteOILType(string keyValue)
 {
     try
     {
         int fId = ConvertVal.GetValInt(keyValue);
         if (_repository.Delete <T_OILType>(p => p.F_ID == fId) > 0)
         {
             return(new { state = true, message = "删除成功!" });
         }
         return(new { state = false, message = "删除失败!" });
     }
     catch (Exception ex)
     {
         return(new { state = false, message = "删除失败!" + ex.ToString() });
     }
 }
示例#3
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="type"></param>
 /// <param name="FileName"></param>
 /// <param name="FilePath"></param>
 /// <param name="F_Description"></param>
 /// <returns></returns>
 public object AddUploadContent(string type, string FileName, string FilePath, string F_Description, string f_date)
 {
     if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(FileName) || string.IsNullOrEmpty(FilePath) || string.IsNullOrEmpty(f_date))
     {
         return(new { state = false, msg = "缺少参数" });
     }
     try
     {
         var _date = DateTime.Parse(f_date);
         var op    = OperatorProvider.Provider.GetCurrent();
         _repository.Insert(new T_UploadContent()
         {
             F_ID          = Guid.NewGuid().ToString("N"),
             F_Filename    = FileName,
             F_Description = F_Description,
             F_Operator    = op.UserCode,
             F_DateTime    = _date,
             F_TypeID      = ConvertVal.GetValInt(type),
             F_Url         = FilePath,
             F_CreateTime  = DateTime.Now
         });
         return(new { state = true });
     }
     catch (DbEntityValidationException dbEx)
     {
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 Code.Logger.LogHelper.Error(string.Format("Class: {0}, Property: {1}, Error: {2}", validationErrors.Entry.Entity.GetType().FullName,
                                                           validationError.PropertyName,
                                                           validationError.ErrorMessage), Code.Enum.OpType.Add);
             }
         }
         return(new { state = false, msg = "操作失败" });
     }
     catch (Exception ex)
     {
         return(new { state = false, msg = ex.ToString() });
     }
 }