public async Task <UpdateOrganizationResponse> Put(UpdateOrganization request) { var user = GetUser(); AssertOrganizationOwner(Db, request.Id, user, out var organization, out var orgMember); var slug = request.Slug; var slugExists = await Db.ExistsAsync <Organization>(x => x.Slug == slug && x.Id != request.Id); if (slugExists) { throw new ArgumentException("Slug already exists", nameof(request.Slug)); } if (organization.Description != request.Description) { organization.DescriptionHtml = await Markdown.TransformAsync(request.Description, user.GetGitHubToken()); } organization.PopulateWith(request); organization.Slug = slug; organization.Modified = DateTime.Now; organization.ModifiedBy = user.UserName; await Db.UpdateAsync(organization); ClearOrganizationCaches(); return(new UpdateOrganizationResponse()); }
///// <summary>Handles a request</summary> ///// <param name="message">The request message</param> ///// <returns>Response from the request</returns> //public int Handle(DeleteOrganizationCommand message) //{ // _session.Delete<Organization>(message.OrganizationId); // _session.SaveChanges(); // return message.OrganizationId; //} public async Task <Guid> Handle(UpdateOrganization message) { var domainEvent = _mapper.Map <OrganizationUpdated>(message); _session.Events.Append(message.Id, domainEvent); await _session.SaveChangesAsync(); return(message.Id); }
/// <summary> /// Edit the settings of an organization This API allows to edit every single setting of an organization except the **slug** field. /// </summary> /// <exception cref="SigningToday.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="organizationId">The **organization-id** represents an organization that is included in the SigninToday application, also know as **slug** and it is used as a path parameter to restrict the asked functionality to the specified organization </param> /// <param name="updateOrganization">The settings of the organization to edit</param> /// <returns>Task of ApiResponse (InlineResponse200)</returns> public async System.Threading.Tasks.Task <ApiResponse <InlineResponse200> > PatchOrganizationAsyncWithHttpInfo(string organizationId, UpdateOrganization updateOrganization) { // verify the required parameter 'organizationId' is set if (organizationId == null) { throw new ApiException(400, "Missing required parameter 'organizationId' when calling OrganizationsApi->PatchOrganization"); } // verify the required parameter 'updateOrganization' is set if (updateOrganization == null) { throw new ApiException(400, "Missing required parameter 'updateOrganization' when calling OrganizationsApi->PatchOrganization"); } var localVarPath = "/organizations/{organization-id}"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (organizationId != null) { localVarPathParams.Add("organization-id", this.Configuration.ApiClient.ParameterToString(organizationId)); // path parameter } if (updateOrganization != null && updateOrganization.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(updateOrganization); // http body (model) parameter } else { localVarPostBody = updateOrganization; // byte array } // authentication (ApiKeyAuth) required if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("Authorization"))) { localVarHeaderParams["Authorization"] = this.Configuration.GetApiKeyWithPrefix("Authorization"); } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.PATCH, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("PatchOrganization", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <InlineResponse200>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), (InlineResponse200)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(InlineResponse200)))); }
/// <summary> /// Edit the settings of an organization This API allows to edit every single setting of an organization except the **slug** field. /// </summary> /// <exception cref="SigningToday.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="organizationId">The **organization-id** represents an organization that is included in the SigninToday application, also know as **slug** and it is used as a path parameter to restrict the asked functionality to the specified organization </param> /// <param name="updateOrganization">The settings of the organization to edit</param> /// <returns>Task of InlineResponse200</returns> public async System.Threading.Tasks.Task <InlineResponse200> PatchOrganizationAsync(string organizationId, UpdateOrganization updateOrganization) { ApiResponse <InlineResponse200> localVarResponse = await PatchOrganizationAsyncWithHttpInfo(organizationId, updateOrganization); return(localVarResponse.Data); }
/// <summary> /// Edit the settings of an organization This API allows to edit every single setting of an organization except the **slug** field. /// </summary> /// <exception cref="SigningToday.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="organizationId">The **organization-id** represents an organization that is included in the SigninToday application, also know as **slug** and it is used as a path parameter to restrict the asked functionality to the specified organization </param> /// <param name="updateOrganization">The settings of the organization to edit</param> /// <returns>InlineResponse200</returns> public InlineResponse200 PatchOrganization(string organizationId, UpdateOrganization updateOrganization) { ApiResponse <InlineResponse200> localVarResponse = PatchOrganizationWithHttpInfo(organizationId, updateOrganization); return(localVarResponse.Data); }
private void metroButUpdateForControlForm_Click(object sender, EventArgs e) { try { if (metroTabControlCF2.SelectedTab.Text == "Организация") { if (metroGridOrganization.SelectedCells.Count != 0) { string ID_Org = manipulationDB.generationID("SELECT ИД FROM Организация " + "WHERE Наименование='" + metroGridOrganization.CurrentRow.Cells[1].Value + "'" + " AND [Дата регистрации]='" + metroGridOrganization.CurrentRow.Cells[2].Value + "' AND" + " [Юридический адрес]='" + metroGridOrganization.CurrentRow.Cells[3].Value + "' AND" + " [Фактический адрес]='" + metroGridOrganization.CurrentRow.Cells[4].Value + "'"); manipulationProgramm.ZapisIndex(ID_Org); UpdateOrganization updateOrganization = new UpdateOrganization(); updateOrganization.Show(); updateOrganization.metroTextBoxNamOrg.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[1].Value); updateOrganization.metroTextBoxDateReg.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[2].Value); updateOrganization.metroTextBoxUrAddress.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[3].Value); updateOrganization.metroTextBoxFactAdress.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[4].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Валюты") { if (metroGridMoney.SelectedCells.Count != 0) { string ID_Val = manipulationDB.generationID("SELECT ИД FROM Валюта" + " WHERE Наименование='" + metroGridMoney.CurrentRow.Cells[1].Value + "' " + "AND [Сокращенное наименование]='" + metroGridMoney.CurrentRow.Cells[2].Value + "'"); manipulationProgramm.ZapisIndex(ID_Val); UpdateMoney updateMoney = new UpdateMoney(); updateMoney.Show(); updateMoney.metroTextBoxFullName.Text = Convert.ToString(metroGridMoney.CurrentRow.Cells[1].Value); updateMoney.metroTextBoxMiniName.Text = Convert.ToString(metroGridMoney.CurrentRow.Cells[2].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Курсы валют") { if (metroGridMoneySize.SelectedCells.Count != 0) { string ID_Val1 = manipulationDB.generationID("SELECT ИД FROM Валюта WHERE [Сокращенное наименование]='" + metroGridMoneySize.CurrentRow.Cells[2].Value + "'"); string ID_Val12 = manipulationDB.generationID("SELECT ИД FROM Валюта WHERE [Сокращенное наименование]='" + metroGridMoneySize.CurrentRow.Cells[4].Value + "'"); string query_Curs = "SELECT ИД FROM [Курс валют] WHERE Единица1=@ed1 AND Валюта1=@val1 AND Единица2=@ed2 AND Валюта2=@val2"; string ID_Curs = ""; try { SqlCommand comm = new SqlCommand(query_Curs, connect); connect.Open(); comm.Parameters.AddWithValue("@ed1", metroGridMoneySize.CurrentRow.Cells[1].Value); comm.Parameters.AddWithValue("@val1", ID_Val1); comm.Parameters.AddWithValue("@ed2", metroGridMoneySize.CurrentRow.Cells[3].Value); comm.Parameters.AddWithValue("@val2", ID_Val12); if (comm.ExecuteScalar() != null) { ID_Curs = comm.ExecuteScalar().ToString(); } else { ID_Curs = ""; } connect.Close(); manipulationProgramm.ZapisIndex(ID_Curs); UpdateMoneySize updateMoneySize = new UpdateMoneySize(); updateMoneySize.Show(); manipulationDB.SelectComboBox("SELECT * FROM Валюта", updateMoneySize.metroComboBoxVal1, "Сокращенное наименование", "ИД"); manipulationDB.SelectComboBox("SELECT * FROM Валюта", updateMoneySize.metroComboBoxVal2, "Сокращенное наименование", "ИД"); updateMoneySize.metroTextBoxSizeMoney1.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[1].Value); updateMoneySize.metroComboBoxVal1.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[2].Value); updateMoneySize.metroTextBoxSizeMoney2.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[3].Value); updateMoneySize.metroComboBoxVal2.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[4].Value); } catch (SqlException exSQL) { MessageBox.Show(exSQL.Message, "Ошибка работы с базой данных:"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка работы с приложением:"); } finally { connect.Close(); } } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Финансовые операции") { if (metroGridFinansedOperation.SelectedCells.Count != 0) { string ID_Oper = manipulationDB.generationID("SELECT * FROM Операция " + "WHERE Наименование='" + metroGridFinansedOperation.CurrentRow.Cells[1].Value + "'"); manipulationProgramm.ZapisIndex(ID_Oper); UpdateFinansedOperation updateFinansedOperation = new UpdateFinansedOperation(); updateFinansedOperation.Show(); updateFinansedOperation.metroTextBoxNamFinOperation.Text = Convert.ToString(metroGridFinansedOperation.CurrentRow.Cells[1].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Паспорт") { if (metroGridPassport.SelectedCells.Count != 0) { string ID_Pass = manipulationDB.generationID("SELECT * FROM Паспорт " + "WHERE ФИО='" + metroGridPassport.CurrentRow.Cells[1].Value + "' AND СиН='" + metroGridPassport.CurrentRow.Cells[2].Value + "'"); manipulationProgramm.ZapisIndex(ID_Pass); UpdatePassport updatePass = new UpdatePassport(); updatePass.Show(); updatePass.metroTextBoxFio.Text = Convert.ToString(metroGridPassport.CurrentRow.Cells[1].Value); updatePass.metroTextBoxSin.Text = Convert.ToString(metroGridPassport.CurrentRow.Cells[2].Value); updatePass.metroTextBoxIdentifity.Text = Convert.ToString(metroGridPassport.CurrentRow.Cells[3].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка:"); } }