public async Task <string> GetAuth(string mail) { Log.Info().Message("AuthConroller Begin"); var data = new Cliente(); var dataAuth = new AuthData(); try { var t1 = AltranDatos.GetClients(); await Task.WhenAll(t1); var rawData = await t1; data = rawData.Clients.Where(x => x.Email == mail).SingleOrDefault(); if (data != null) { dataAuth.email = data.Email; dataAuth.role = data.Role; dataAuth.validuntil = DateTime.Now.AddHours(8); } else { throw new ArgumentNullException("Usuario no Conseguido"); } } catch (Exception ex) { Log.Error().Exception(ex); Log.Error().Message(ex.StackTrace); } return(GenerarTokenJWT(dataAuth)); }
public async Task GetAuth_GetingUserDataByMailAsync() { //Arrange string expected = "[{\"Id\":\"a0ece5db-cd14-4f21-812f-966633e7be86\",\"Name\":\"Britney\",\"Email\":\"[email protected]\",\"Role\":\"admin\"}]"; //Act var t1 = AltranDatos.GetClients(); await Task.WhenAll(t1); var rawData = await t1; var data = rawData.Clients; string actual = JsonConvert.SerializeObject(data.Where(x => x.Email == "*****@*****.**")); //Assert Assert.AreEqual(expected, actual); }
public async Task GetClients_GetingCorrectAmountOfElementAsync() { //Arrange int expected = 194; //Act var t1 = AltranDatos.GetClients(); await Task.WhenAll(t1); var rawData = await t1; var data = rawData.Clients; int actual = data.Count(); //Assert Assert.AreEqual(expected, actual); }
public async Task <string> GetById(string id) { var data = new LClientes().Clients; try { var t1 = AltranDatos.GetClients(); await Task.WhenAll(t1); var rawData = await t1; data = rawData.Clients.Where(x => x.Id == id); } catch (Exception ex) { Log.Error().Exception(ex); } return(JsonConvert.SerializeObject(data)); }
public async Task <string> GetByName(string name) { //TODO: Autorization var data = new LClientes().Clients; try { var t1 = AltranDatos.GetClients(); await Task.WhenAll(t1); var rawData = await t1; data = rawData.Clients.Where(x => x.Name == name); } catch (Exception ex) { Log.Error().Exception(ex); } return(JsonConvert.SerializeObject(data)); }
public async Task <string> GetByName(string name) { //TODO: Autorization var data = new LPolizas().Policies; try { var t0 = AltranDatos.GetClients(); var t1 = AltranDatos.GetPolicies(); await Task.WhenAll(t0, t1); var rawData0 = await t0; var rawData = await t1; string _cliendId = rawData0.Clients.Where(x => x.Name == name).SingleOrDefault().Id; data = rawData.Policies.Where(x => x.ClientId == _cliendId); } catch (Exception ex) { Log.Error().Exception(ex); } return(JsonConvert.SerializeObject(data)); }