/// <summary>
 /// Kiểm tra và thêm mới Im_category
 /// </summary>
 /// <param name="entity">Entity</param>
 /// <returns>Int32: ID của Im_category Mới Thêm Vào</returns>
 public static Int32 Add(Im_categoryEntity entity)
 {
     checkLogic(entity);
     checkDuplicate(entity, false);
     checkFK(entity);
     return Im_categoryDAL.Add(entity);
 }
 /// <summary>
 /// Kiểm tra và chỉnh sửa Im_category
 /// </summary>
 /// <param name="entity">Im_categoryEntity</param>
 /// <returns>bool:kết quả thực hiện</returns>
 public static bool Edit(Im_categoryEntity entity)
 {
     checkExist(entity._id);
     checkLogic(entity);
     checkDuplicate(entity, true);
     checkFK(entity);
     return Im_categoryDAL.Edit(entity);
 }
 /// <summary>
 /// Kiểm tra trùng lặp bản ghi
 /// </summary>
 /// <param name="entity">Im_categoryEntity: Im_categoryEntity</param>
 private static void checkDuplicate(Im_categoryEntity entity,bool checkPK)
 {
     /*
     Example
     List<Im_categoryEntity> list = Im_categoryDAL.GetAll();
     if (list.Exists(
         delegate(Im_categoryEntity oldEntity)
         {
             bool result =oldEntity.FIELD.Equals(entity.FIELD, StringComparison.OrdinalIgnoreCase);
             if(checkPK)
                 result=result && oldEntity.PK_iIm_categoryID != entity.PK_iIm_categoryID;
             return result;
         }
     ))
     {
         list.Clear();
         throw new Exception(EX_FIELD_EXISTED);
     }
     */
 }
 /// <summary>
 /// Kiểm tra logic Entity
 /// </summary>
 /// <param name="entity">Im_categoryEntity: entity</param>
 private static void checkLogic(Im_categoryEntity entity)
 {
     //if (String.IsNullOrEmpty(entity.sLastname))
     //    throw new Exception(EX_SLASTNAME_EMPTY);
 }
 /// <summary>
 /// Kiểm tra tồn tại khóa ngoại
 /// </summary>
 /// <param name="entity">Im_categoryEntity:entity</param>
 private static void checkFK(Im_categoryEntity entity)
 {
 }