예제 #1
0
        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);
        }
예제 #2
0
        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());
        }
예제 #3
0
        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;
        }
예제 #5
0
        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);
        }
예제 #6
0
        private void button4_Click(object sender, EventArgs e)
        {
            //this.Hide();
            CompanyCreation frm = new CompanyCreation();

            this.Visible = false;
            frm.ShowDialog();
            this.Visible = true;
        }
예제 #7
0
        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)));
        }
예제 #8
0
 public async Task <Company> CreateCompanyAsync(CompanyCreation companyData)
 {
     return(_mapper.Map <Company>(
                await _companyCommand.CreateCompanyAsync(
                    _mapper.Map <Database.Entities.Company>(companyData))));
 }