public async Task <DataProviderModel <List <Region> > > GetRegions() { List <Query> listQuery = new List <Query>(); string q_guid = Guid.NewGuid().ToString(); Query query = new Query(q_guid, "GetRegions"); listQuery.Add(query); var result = await _queryExecutorDecorator.Execute(listQuery).ConfigureAwait(false); var getRegionsQuery = result.Queries.FirstOrDefault(q => q.Name == "GetRegions"); var regions = new List <Region>(); if (getRegionsQuery != null) { var dataTable = getRegionsQuery.RetTable; foreach (DataRow objectRow in dataTable.Rows) { regions.Add(new Region( objectRow["CODE"].ToString(), objectRow["NAME"].ToString() )); } } return(new DataProviderModel <List <Region> >(result.ResultMessage, regions)); }
public async Task <DataProviderModel <AuthModel> > Authenticate(string email, string passwordHash) { string queryIdentifier = Guid.NewGuid().ToString(); var query = new Query(queryIdentifier, "AuthSession"); query.Parameters.Add(new QueryParameter("in", "Login", email)); query.Parameters.Add(new QueryParameter("in", "PasswordHash", passwordHash)); query.Parameters.Add(new QueryParameter("in", "SocAccount_Name", "Email")); var result = await _appQueryExecutor.Execute(new List <Query> { query }).ConfigureAwait(false); var model = new DataProviderModel <AuthModel>(result.ResultMessage, null); foreach (var q1 in result.Queries) { if (q1.Name == "AuthSession" && q1.Parameters.Exists(x => x.Code == "SocAccount_Name" && x.Value == "Email")) { if (q1.Parameters.Exists(x => x.Code == "Session_Id" && x.Direction == "out")) { model.Model = new AuthModel(q1.Parameters.Find(x => x.Code == "UserName" && x.Direction == "out").Value, q1.Parameters.Find(x => x.Code == "Session_Id" && x.Direction == "out").Value); } } } return(model); }
public async Task <DataProviderModel <List <ObjectCategory> > > GetCategories() { List <Query> listQuery = new List <Query>(); string q_guid = Guid.NewGuid().ToString(); Query query = new Query(q_guid, "GetObjectCategories"); listQuery.Add(query); var result = await _queryExecutorDecorator.Execute(listQuery).ConfigureAwait(false); var getCitiesQuery = result.Queries.FirstOrDefault(q => q.Name == "GetObjectCategories"); var categories = new List <ObjectCategory>(); if (getCitiesQuery != null) { var dataTable = getCitiesQuery.RetTable; foreach (DataRow objectRow in dataTable.Rows) { categories.Add(new ObjectCategory( objectRow["ObjectCategory_Id"].ToString(), objectRow["ObjectCategory_Name"].ToString() )); } } return(new DataProviderModel <List <ObjectCategory> >(result.ResultMessage, categories)); }
public async Task <DataProviderModel <CreatedUserModel> > CreateUser(string email, string userName, string passwordHash) { var queryIdetifier = Guid.NewGuid().ToString(); var query = new Query(queryIdetifier, "CreateUser"); query.Parameters.Add(new QueryParameter("in", "Email", email)); query.Parameters.Add(new QueryParameter("in", "UserName", userName)); query.Parameters.Add(new QueryParameter("in", "PasswordHash", passwordHash)); query.Parameters.Add(new QueryParameter("in", "SocAccount_Name", "Email")); query.Parameters.Add(new QueryParameter("in", "isNeedToAuth", "Y")); var result = await _appQueryExecutor.Execute(new List <Query> { query }).ConfigureAwait(false); var model = new DataProviderModel <CreatedUserModel>(result.ResultMessage, null); foreach (var q1 in result.Queries) { if (q1.Name == "CreateUser") { if (q1.Parameters.Exists(x => x.Code == "UserSession_Id")) { model.Model = new CreatedUserModel(q1.Parameters.Find(x => x.Code == "UserSession_Id").Value); } } } return(model); }
public async Task <DataProviderModel <List <DeleveryType> > > GetDeleveryTypes() { var q1_guid = Guid.NewGuid().ToString(); var q1 = new Query(q1_guid, "GetCptyServices"); q1.Parameters.Add(new QueryParameter("in", "CptyType_Code", "Delivery")); var listQuery = new List <Query> { q1 }; var result = await _appQueryExecutorDecorator.Execute(listQuery).ConfigureAwait(false); var getDeliverTypesQuery = result.Queries.FirstOrDefault(q => q.Name == "GetCptyServices"); var deliveryTypes = new List <DeleveryType>(); if (getDeliverTypesQuery != null) { var dataTable = getDeliverTypesQuery.RetTable; foreach (DataRow objectRow in dataTable.Rows) { deliveryTypes.Add(new DeleveryType(objectRow["CptyService_Id"].GetInt(), objectRow["Name"].ToString())); } } return(new DataProviderModel <List <DeleveryType> >(result.ResultMessage, deliveryTypes)); }