private void RemoveClick(object sender, RoutedEventArgs e) { try { if (SharedClass.MessageBoxQuestion("Вы уверены что хотите удалить клиента?") == MessageBoxResult.No) { return; } if (IsSelectedClient()) { Client client = displayClientRep.GetClient(GetSelectedDisplayClient()); clientRep.RemoveClient(client); UpdateList(); SharedClass.MessageBoxInformation("Клиент успешно удален"); } } catch (Exception ex) { SharedClass.MessageBoxError(ex); } }
/// <summary> /// Button Click. Send request and get responce /// </summary> private void GoClick(object sender, RoutedEventArgs e) { try { if (!string.IsNullOrWhiteSpace(this.TxtUrl.Text)) { //get url request string url = this.TxtUrl.Text; //get method request Methods method = (Methods)this.CmbMethods.SelectedItem; //check condition body if (string.IsNullOrWhiteSpace(this.TxtBody.Text) && (method.Equals(Methods.POST) || method.Equals(Methods.PUT))) { if (SharedClass.MessageBoxQuestion("Body is Empty. Continue?") == MessageBoxResult.No) { return; } } //request generation RestClient restClient = new RestClient(url, method); restClient.MakeRequest(); if (method == Methods.POST || method == Methods.PUT) { string body = this.TxtBody.Text; restClient.SetBody(body); } //call request and get responce Request request = restClient.GetResponce(); //pretty json string responce = request.Responce; if (request.Method == Methods.GET) { responce = Serialization.GetJsonSerialize(request.Responce); } SetResponce(responce); //add object and update history if (request.Responce.Length > History.MAXLENGHTRESPONCE) { request.Responce = request.Responce.Substring(0, History.MAXLENGHTRESPONCE); } UpdateHistory(request); } else { SharedClass.MessageBoxWarning("Enter the URL address"); } } catch (UriFormatException ufe) { SharedClass.MessageBoxWarning("Invalid URL format", "URL Format"); } catch (Exception ex) { SharedClass.MessageBoxError(ex); } }