public MainApplication(RestClient client) { InitializeComponent(); this.newClient = client; stand = newClient.GetLoanStand(); radioButton1.Text = Type.ELECTRONICS.ToString(); radioButton2.Text = Type.OTHER.ToString(); SetUpVideoSources(); }
public AddProduct(RestClient newClient, Loan_Stand stand, MainApplication main) { InitializeComponent(); newStand = stand; client = newClient; mainApp = main; typeCb.Items.Add(Type.ELECTRONICS); typeCb.Items.Add(Type.OTHER); }
public UpdateItem(RestClient newClient, Loan_Stand stand, MainApplication app) { InitializeComponent(); client = newClient; newStand = stand; mainApp = app; newStand.Items = client.RequestItems(); foreach (Item item in stand.Items) { IdNameCb.Items.Add(item.ID + " " + item.Name); } }
public Loan_Stand GetLoanStand() { Loan_Stand stand = null; EndPoint = "http://localhost:8080/stands"; string strResponseValue = string.Empty; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(EndPoint); request.ContentType = "application/json"; request.Method = "GET"; request.CookieContainer = cookieContainer; try { using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { throw new ApplicationException("Error connecting with the server!"); } using (Stream responseStream = response.GetResponseStream()) { if (responseStream != null) { using (StreamReader reader = new StreamReader(responseStream)) { strResponseValue = reader.ReadLine(); } } } } }catch (WebException webExc) { MessageBox.Show(webExc.Message); } //Deserializing responce into Loan_Stand object JavaScriptSerializer serializer = new JavaScriptSerializer(); var item = serializer.Deserialize <List <Loan_Stand> >(strResponseValue); foreach (Loan_Stand stands in item) { stand = stands; } return(stand); }