private static DataTable ConvertToUDTT(CompanyCreation companyCreation) { DataTable table = new DataTable(); table.SetTypeName("[dbo].[UDTT_bigIntCoupleList]"); DataColumn userId = new DataColumn("Value1", typeof(long)); table.Columns.Add(userId); DataColumn profileId = new DataColumn("Value2", typeof(long)); table.Columns.Add(profileId); foreach (var item in companyCreation.CompanyUserProfile) { var row = table.NewRow(); row[userId] = item.UserId; row[profileId] = item.ProfileId; table.Rows.Add(row); } return(table); }
public async Task <Message> Postdepartment([FromBody] CompanyCreation companyCreation) { if (companyCreation == null || string.IsNullOrEmpty(companyCreation.ParentId)) { return(Message.Fail().Add("content", "未选择上级部门")); } var dbcom = await _companyRepository.GetSingleAsync(x => x.Id == companyCreation.ParentId); if (dbcom == null) { return(Message.Fail().Add("content", "上级部门不存在")); } var dbitem = await _companyRepository.GetSingleAsync(x => x.Name == companyCreation.Name); if (dbitem != null) { return(Message.Fail().Add("content", "部门重复")); } companyCreation.Id = Method.GetGuid32(); // companyCreation.ParentId = "0"; var newItem = _mapper.Map <Company>(companyCreation); _companyRepository.Add(newItem); if (!await _unitOfWork.SaveAsync()) { return(Message.ServerError()); } return(Message.Ok()); }
public async Task <Message> PostCompany([FromBody] CompanyCreation companyCreation) { if (companyCreation == null) { return(Message.Fail()); } var dbitem = await _companyRepository.GetSingleAsync(x => x.Name == companyCreation.Name); if (dbitem != null) { return(Message.Fail().Add("content", "公司重复")); } companyCreation.Id = Method.GetGuid32(); companyCreation.ParentId = "0"; var newItem = _mapper.Map <Company>(companyCreation); _companyRepository.Add(newItem); if (!await _unitOfWork.SaveAsync()) { return(Message.ServerError()); } return(Message.Ok()); }
private void NewComCreationButton_Click(object sender, EventArgs e) { this.Hide(); CompanyCreation f2 = new CompanyCreation(); this.Visible = false; f2.ShowDialog(); this.Visible = true; }
public async Task CreateUserProfile(int companyId, CompanyCreation companyCreation) { var queryParameters = new DynamicParameters(); queryParameters.Add("@UserProfile", ConvertToUDTT(companyCreation)); queryParameters.Add("@CompanyToCopy", companyCreation.CompanyToCopy); queryParameters.Add("@CompanyId", companyId); await ExecuteNonQueryAsync(StoredProcedureNames.CreateUserCompanyProfile, queryParameters, true); }
private void button4_Click(object sender, EventArgs e) { //this.Hide(); CompanyCreation frm = new CompanyCreation(); this.Visible = false; frm.ShowDialog(); this.Visible = true; }
public async Task <ActionResult> CreateCompanyAsync([FromBody] CompanyCreation newCompanyData) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var createdCompany = await _companyService.CreateCompanyAsync(newCompanyData); return(Created($"/companies/{createdCompany.Id}", _mapper.Map <DTO.Response.Company>(createdCompany))); }
public async Task <Company> CreateCompanyAsync(CompanyCreation companyData) { return(_mapper.Map <Company>( await _companyCommand.CreateCompanyAsync( _mapper.Map <Database.Entities.Company>(companyData)))); }