public Member post([FromBody] Member member) { try { if (!bConnectToAPI.HasValue) { string s = (new ConfigurationBuilder()).AddJsonFile("appsettings.json").Build().GetSection("CustomVariables")["ConnectToAPI"]; bConnectToAPI = string.IsNullOrEmpty(s) ? false : s == "Yes" ? true : false; } if (bConnectToAPI.Value) { return(APIHandler <Member> .PostMethod("https://localhost:44367/Members", member)); } else { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); test.AddMember(member); return(member); } } catch (Exception ex) { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); return(UIIndependentTest.Members.FirstOrDefault()); } }
public IEnumerable <Member> Get() { try { if (!bConnectToAPI.HasValue) { string s = (new ConfigurationBuilder()).AddJsonFile("appsettings.json").Build().GetSection("CustomVariables")["ConnectToAPI"]; bConnectToAPI = string.IsNullOrEmpty(s) ? false : s == "Yes" ? true : false; } if (bConnectToAPI.Value) { return(APIHandler <IEnumerable <Member> > .GetMethod("https://localhost:44367/Members")); } else { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); return(UIIndependentTest.Members.ToArray()); } } catch (Exception ex) { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); return(UIIndependentTest.Members.ToArray()); } }
public LoginStatus Post([FromBody] LoginRequest user) { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); User u = UIIndependentTest.Users.ToArray().Where(x => x.UserName == user.UserName).FirstOrDefault(); test.TestHash(u); if (u == null) { return(new LoginStatus() { message = "User name or password is not valid", status = false }); } else { LoginStatus ret = new LoginStatus() { message = "Successfully logged in", status = true }; if (u.EncryptedAccessKey != UIIndependentTest.GetKey(user.Password)) { ret.message = "User name or password is not valid"; ret.status = false; } return(ret); } }
public Product post([FromBody] Product pProduct) //string product { try { if (!bConnectToAPI.HasValue) { string s = (new ConfigurationBuilder()).AddJsonFile("appsettings.json").Build().GetSection("CustomVariables")["ConnectToAPI"]; bConnectToAPI = string.IsNullOrEmpty(s) ? false : s == "Yes" ? true : false; } if (bConnectToAPI.Value) { return(APIHandler <Product> .PostMethod("https://localhost:44303/Products", pProduct)); } else { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); test.AddProduct(pProduct); return(pProduct); } } catch (Exception ex) { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); return(UIIndependentTest.Products.FirstOrDefault()); } }
public IEnumerable <User> Get() { UIIndependentTest test = new UIIndependentTest(); test.LoadTestData(); return(UIIndependentTest.Users.ToArray()); }