Пример #1
0
        public async Task <bool> Login(User user)
        {
            using (var con = new SqlConnection(this._connectionString))
            {
                try
                {
                    var result = _entityFrameworkDbContext.Set <User>() as IQueryable <User>;

                    var slectUser = result.Where(x => x.Password.Equals(_helpers.Encrypt(user.Password)) && x.Username.Equals(user.Username));

                    return(slectUser.Count() > 0 ? true : false);
                }
                catch (Exception e)
                {
                    this._logger.LogError($"Getting the data from config.AuthorizationRoles on config database failed: {e.Message}.");
                    throw;
                }
            }
        }
        public bool AddDefender(Defender defender)
        {
            try
            {
                _entityFrameworkDbContext.Set <Defender>().Add(defender);
                _entityFrameworkDbContext.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                this._logger.LogError($"Getting the data from config.AuthorizationRoles on config database failed: {e.Message}.");
                throw;
            }
        }
Пример #3
0
 public override TAggregateRoot GetByKey(long key)
 {
     return(dbContext.Set <TAggregateRoot>().FirstOrDefault(p => p.Id == key));
 }
Пример #4
0
 public static bool ExistsLocal <T>(this IEntityFrameworkDbContext dbContext, T entity) where T : class
 {
     return(dbContext.Set <T>().Local.Contains(entity));
 }
Пример #5
0
 public static T FirstOrDefautLocal <T>(this IEntityFrameworkDbContext dbContext, Func <T, bool> predicate) where T : class
 {
     return(dbContext.Set <T>().Local.FirstOrDefault(predicate));
 }
Пример #6
0
 public static bool ExistsLocal <T>(this IEntityFrameworkDbContext dbContext, Func <T, bool> predicate) where T : class
 {
     return(dbContext.Set <T>().Local.Any(predicate));
 }