Ejemplo n.º 1
0
        public async Task <ApplyBaseInfo> SubmitBaseInfoAsync(ApplyBaseInfoVdto model)
        {
            if (model == null)
            {
                return(null);
            }
            var m = new ApplyBaseInfo()
            {
                Company  = await context.CompaniesDb.FirstOrDefaultAsync(c => c.Code == model.Company).ConfigureAwait(true),
                Duties   = await context.Duties.FirstOrDefaultAsync(d => d.Name == model.Duties).ConfigureAwait(true),
                From     = model.From,
                CreateBy = model.CreateBy,
                Social   = new UserSocialInfo()
                {
                    Address       = await context.AdminDivisions.FindAsync(model.VacationTargetAddress).ConfigureAwait(true),
                    AddressDetail = model.VacationTargetAddressDetail,
                    Phone         = model.Phone,
                    Settle        = model.Settle              // 此处可能需要静态化处理,但考虑到.History问题,再议
                },
                RealName    = model.RealName,
                CompanyName = model.Company,
                DutiesName  = model.Duties,
                CreateTime  = DateTime.Now
            };

            if (m.Company != null)
            {
                m.CompanyName = m.Company.Name;
            }
            await context.ApplyBaseInfos.AddAsync(m).ConfigureAwait(true);

            await context.SaveChangesAsync().ConfigureAwait(true);

            return(m);
        }
 public static ApplyBaseInfoDto ToDto(this ApplyBaseInfo model)
 {
     return(new ApplyBaseInfoDto()
     {
         CompanyName = model?.CompanyName,
         DutiesName = model.DutiesName,
         RealName = model.RealName,
     });
 }