コード例 #1
0
        /// <summary>
        /// Kiểm tra dữ liệu có tồn tại trong database không
        /// </summary>
        /// <param name="id">id của entity</param>
        /// <param name="errorMsg">Thông báo lỗi</param>
        /// <returns>true - tồn tại, false - không tồn tại</returns>
        protected virtual bool IsDataExist(string id, ErrorMsg errorMsg = null)
        {
            var idInDb = _dbContext.CheckEntityIdExist(id);

            if (errorMsg == null)
            {
                errorMsg = new ErrorMsg();
            }
            if (idInDb != null)
            {
                return(true);
            }
            errorMsg.UserMsg.Add(Resources.ErrorService_IdNotExist);
            return(false);
        }