private void RegisterButtonClicked(object sender, RoutedEventArgs e) { CreateServiceFromInputData(); if (ValidateDataService()) { if (isImage) { RegisterService(); if (serviceGenerate.idService > Number.NumberValue(NumberValues.ZERO)) { CreateResourceFromInputData(); RegisterResource(); if (isRegisterImage) { MessageBox.Show("El servicio se registró exitosamente", "Registro exitoso", MessageBoxButton.OK, MessageBoxImage.Information); HomeEmployee home = new HomeEmployee(); home.InitializeMenu(); home.Show(); Close(); } } } else { MessageBox.Show("Por favor ingresa una foto de principal del servicio", "Ingresa foto", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Por favor, Ingrese datos correctos en los campos marcados en rojo", "Datos invalidos", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void ListViewMenuSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs) { switch (((ListViewItem)((ListView)sender).SelectedItem).Name) { case "ListViewItemHome": HomeEmployee home = new HomeEmployee(); home.InitializeMenu(); home.Show(); Close(); break; case "ListViewItemAccountEdit": AccountEdition accountEdition = new AccountEdition(); accountEdition.InitializeMenu(); accountEdition.Show(); Close(); break; case "ListViewItemBehind": ServiceOffered serviceOffered = new ServiceOffered(); serviceOffered.InitializeMenu(); serviceOffered.Show(); Close(); break; case "ListViewItemChat": ChatList chatList = new ChatList(); chatList.InitializeMenu(); chatList.Show(); Close(); break; case "ListViewItemRequest": RequestsReceivedList requestReceivedList = new RequestsReceivedList(); requestReceivedList.InitializeMenu(); requestReceivedList.Show(); Close(); break; case "ListViewItemServiceRegistration": ServiceRegistry serviceRegistry = new ServiceRegistry(); serviceRegistry.InitializeMenu(); serviceRegistry.Show(); Close(); break; case "ListViewItemCommentTracing": ReportGeneration reportGeneration = new ReportGeneration(); reportGeneration.InitializeMenu(); reportGeneration.Show(); Close(); break; default: break; } }
private void RegisterService() { serviceGenerate = new Models.Service(); RestClient client = new RestClient(urlBase); client.Timeout = -1; var request = new RestRequest("services", Method.POST); foreach (RestResponseCookie cookie in Login.cookies) { request.AddCookie(cookie.Name, cookie.Value); } var json = JsonConvert.SerializeObject(service); request.AddHeader("Token", Login.tokenAccount.token); request.AddParameter("application/json", json, ParameterType.RequestBody); System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); }; try { IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK) { serviceGenerate = JsonConvert.DeserializeObject <Models.Service>(response.Content); } else { Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content); if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.RequestTimeout) { BehindLogin(responseError.error); } else { MessageBox.Show(responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error); if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest) { HomeEmployee home = new HomeEmployee(); home.InitializeMenu(); home.Show(); Close(); } } } } catch (Exception exception) { TelegramBot.SendToTelegram(exception); LogException.Log(this, exception); MessageBox.Show("No se pudo registrar el servicio. Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error); HomeEmployee home = new HomeEmployee(); home.InitializeMenu(); home.Show(); Close(); } }
private void RegisterResource() { RestClient client = new RestClient(urlBase); client.Timeout = -1; var request = new RestRequest("resources", Method.POST); request.AddParameter("isMainResource", resource.isMainResource); request.AddParameter("name", resource.name); request.AddParameter("idService", resource.idService); request.AddParameter("idMemberATE", resource.idMemberATE); request.AddFile("resourceFile", routeImage); request.AddHeader("Token", Login.tokenAccount.token); request.AddHeader("Content-Type", "multipart/form-data"); System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); }; try { IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK) { var responseOk = JsonConvert.DeserializeObject <dynamic>(response.Content); isRegisterImage = true; } else { Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content); if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.RequestTimeout) { BehindLogin(responseError.error); } else { MessageBox.Show("El servicio se registro. Pero " + responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error); if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest) { HomeEmployee home = new HomeEmployee(); home.InitializeMenu(); home.Show(); Close(); } } } } catch (Exception exception) { TelegramBot.SendToTelegram(exception); LogException.Log(this, exception); MessageBox.Show("El servicio se registro. Pero no se pudo registrar el recurso.Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error); HomeEmployee home = new HomeEmployee(); home.InitializeMenu(); home.Show(); Close(); } }
private void CancelButtonClicked(object sender, RoutedEventArgs e) { if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); }
private void ListViewMenuSelectionChanged(object sender, SelectionChangedEventArgs e) { switch (((ListViewItem)((ListView)sender).SelectedItem).Name) { case "ListViewItemHome": if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE)) { HomeClient home = new HomeClient(); home.InitializeMenu(); home.Show(); Close(); } else { HomeEmployee home = new HomeEmployee(); home.InitializeMenu(); home.Show(); Close(); } break; case "ListViewItemChat": ChatList chatList = new ChatList(); chatList.InitializeMenu(); chatList.Show(); Close(); break; case "ListViewItemRequest": if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE)) { RequestsMadeList requestsMadeList = new RequestsMadeList(); requestsMadeList.InitializeMenu(); requestsMadeList.Show(); Close(); } else { RequestsReceivedList requestReceivedList = new RequestsReceivedList(); requestReceivedList.InitializeMenu(); requestReceivedList.Show(); Close(); } break; case "ListViewItemServiceRegistration": if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE)) { AccountActivate accountActivate = new AccountActivate(); accountActivate.InitializeMenu(); accountActivate.Show(); Close(); } else { ServiceRegistry serviceRegistry = new ServiceRegistry(); serviceRegistry.InitializeMenu(); serviceRegistry.Show(); Close(); } break; case "ListViewItemCommentTracing": if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.ONE)) { CommentClient commentClient = new CommentClient(); commentClient.InitializeMenu(); commentClient.Show(); Close(); } else { ReportGeneration reportGeneration = new ReportGeneration(); reportGeneration.InitializeMenu(); reportGeneration.Show(); Close(); } break; default: break; } }
private void DeleteResource() { RestClient client = new RestClient(urlBase); client.Timeout = -1; string urlResource = "resources/" + resource.routeSave; var request = new RestRequest(urlResource, Method.DELETE); foreach (RestResponseCookie cookie in Login.cookies) { request.AddCookie(cookie.Name, cookie.Value); } request.AddHeader("Token", Login.tokenAccount.token); System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); }; try { IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK) { var responseOk = JsonConvert.DeserializeObject <dynamic>(response.Content); isDeleteImage = true; } else { Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content); if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.RequestTimeout) { BehindLogin(responseError.error); } else { MessageBox.Show("La cuenta se modificó. Pero " + responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error); if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest) { if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); } } } } catch (Exception exception) { TelegramBot.SendToTelegram(exception); LogException.Log(this, exception); MessageBox.Show("La cuenta se modificó. Pero no se pudo registrar el recurso.Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error); if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); } }
private void UpdateMemberATE() { RestClient client = new RestClient(urlBase); client.Timeout = -1; string urlMemberATE = "accounts/" + memberATE.idAccount; var request = new RestRequest(urlMemberATE, Method.PUT); foreach (RestResponseCookie cookie in Login.cookies) { request.AddCookie(cookie.Name, cookie.Value); } var json = JsonConvert.SerializeObject(memberATE); request.AddHeader("Token", Login.tokenAccount.token); request.AddParameter("application/json", json, ParameterType.RequestBody); System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return(true); }; try { IRestResponse response = client.Execute(request); if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK) { memberATE = JsonConvert.DeserializeObject <Models.MemberATE>(response.Content); Login.loginAccount.username = memberATE.username; isUpdateMember = true; } else { Models.Error responseError = JsonConvert.DeserializeObject <Models.Error>(response.Content); if (response.StatusCode == System.Net.HttpStatusCode.Forbidden || response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.RequestTimeout) { BehindLogin(responseError.error); } else { MessageBox.Show(responseError.error, "Error", MessageBoxButton.OK, MessageBoxImage.Error); if (response.StatusCode != System.Net.HttpStatusCode.Conflict && response.StatusCode != System.Net.HttpStatusCode.BadRequest) { if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); } } } } catch (Exception exception) { TelegramBot.SendToTelegram(exception); LogException.Log(this, exception); MessageBox.Show("No se pudo modificar la cuenta. Intente más tarde", "Error", MessageBoxButton.OK, MessageBoxImage.Error); if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); } }
private void SaveButtonClicked(object sender, RoutedEventArgs routedEventArgs) { CreateMemberATEFromInputData(); if (ValidateDataMemberATE()) { if (ValidateDateBirth()) { UpdateMemberATE(); if (isUpdateMember) { if (isEditImage) { if (resource.routeSave != null) { DeleteResource(); if (isDeleteImage) { CreateResourceFromInputData(); RegisterResource(); if (isRegisterImage) { MessageBox.Show("La cuenta se modificó exitosamente", "Modificación exitosa", MessageBoxButton.OK, MessageBoxImage.Information); if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); } } } else { CreateResourceFromInputData(); RegisterResource(); if (isRegisterImage) { MessageBox.Show("La cuenta se modificó exitosamente", "Modificación exitosa", MessageBoxButton.OK, MessageBoxImage.Information); if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); } } } else { MessageBox.Show("La cuenta se modificó exitosamente", "Modificación exitosa", MessageBoxButton.OK, MessageBoxImage.Information); if (Login.tokenAccount.memberATEType == Number.NumberValue(NumberValues.TWO)) { HomeEmployee homeEmployee = new HomeEmployee(); homeEmployee.InitializeMenu(); homeEmployee.Show(); } else { HomeClient homeClient = new HomeClient(); homeClient.InitializeMenu(); homeClient.Show(); } Close(); } } } else { MessageBox.Show("La fecha no concuerda con la Edad adecuada", "Fecha invalida", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Por favor, Ingrese datos correctos en los campos marcados en rojo", "Datos invalidos", MessageBoxButton.OK, MessageBoxImage.Warning); } }