Exemple #1
0
        /// <summary>
        /// /// [Chuc.Nguyen] - Hàm dùng chung cho thực hiện lệnh theo list para có sử dụng hay ko sử dụng cursor
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="listParameter"></param>
        /// <param name="storeName"></param>
        /// <param name="useCursor"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public List <TEntity> ActionData <TEntity>(List <object> listParameter, string storeName, bool useCursor, string userLogin, ref string status) where TEntity : class
        {
            using (var context = new VnrHrmDataContext())
            {
                List <TEntity> listEntity = new List <TEntity>();
                var            unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var            repo       = new CustomBaseRepository <TEntity>(unitOfWork);
                try
                {
                    listEntity = repo.ExecuteQuery(listParameter, storeName, useCursor, userLogin, ref status).ToList();
                }
                catch (Exception ex)
                {
                    listEntity = null;
                    status     = NotificationType.Error + "," + ex.Message;
                }

                return(listEntity);
            }
        }
Exemple #2
0
 /// <summary>
 /// [Chuc.Nguyen] - Chạy câu query theo sử dụng Store theo Dictionary điều kiện key/value
 /// </summary>
 /// <param name="value"></param>
 /// <param name="storeName">Tên store lấy dữ liệu</param>
 /// <returns></returns>
 public string SaveData <TEntity>(Dictionary <object, object> value, string storeName) where TEntity : class
 {
     using (var context = new VnrHrmDataContext())
     {
         var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
         var repo       = new CustomBaseRepository <TEntity>(unitOfWork);
         try
         {
             string status = string.Empty;
             foreach (var item in value)
             {
                 if (item.Value != null)
                 {
                     var checkExistName = GetData <TEntity>(item.Key, ConstantSql.hrm_cat_sp_get_GetAllSettings, string.Empty, ref status);
                     if (checkExistName != null && checkExistName.Count > 0)
                     {
                         List <object> listObj = new List <object>();
                         listObj.Add(item.Key);
                         listObj.Add(item.Value);
                         repo.ExecuteQuery(listObj, storeName, false, string.Empty, ref status).ToList <object>();
                     }
                     else
                     {
                         var entity = (TEntity)typeof(TEntity).CreateInstance();
                         entity.SetPropertyValue("Name", item.Key);
                         entity.SetPropertyValue("Value1", item.Value);
                         entity.SetPropertyValue("UserID", Guid.NewGuid());
                         Add <TEntity>(entity);
                         //repo.Add(entity);
                         //repo.SaveChanges();
                     }
                 }
             }
             return(status);
         }
         catch (Exception ex)
         {
             return(NotificationType.Error + "," + ex.Message);
         }
     }
 }