Exemplo n.º 1
0
 /// <summary>
 /// Deletes and retrieves the deleted item from database
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Instrument Delete(int id)
 {
     if (id != 0)
     {
         var instrument = instrumentRepository.Delete(id);
         instrumentRepository.Commit();
         return(instrument);
     }
     logger.WriteLog("Failed to delete iteam with id " + id, LogLevel.Warning);
     return(null);
 }
Exemplo n.º 2
0
        public async Task <TEntity> FindOneAsync(long id)
        {
            var toReturn = await _context.Set <TEntity>().FindAsync(id);

            if (toReturn is null)
            {
                Log.WriteLog($"Did not found {typeof(TEntity).Name} with {id}", Microsoft.Extensions.Logging.LogLevel.Information);
            }
            else
            {
                Log.WriteLog($"FindOne {typeof(TEntity).Name} with {id}", Microsoft.Extensions.Logging.LogLevel.Information);
            }
            return(toReturn);
        }
Exemplo n.º 3
0
        public async Task <UserDto> Login(string username, string password)
        {
            if (!string.IsNullOrWhiteSpace(username) || !string.IsNullOrWhiteSpace(password))
            {
                var aux = await repository.GetAllAsync();

                var toParse = aux.FirstOrDefault(x => (x.UserName.Equals(username) && x.Password.Equals(EncryptPassword(password))));
                if (toParse == null)
                {
                    logger.WriteLog($"Username not found", Microsoft.Extensions.Logging.LogLevel.Warning);
                    return(null);
                }
                var result = DTO.DTO.UserToDto(toParse);
                result.Logged = true;
                return(result);
            }
            return(null);
        }