public async Task <GetPersonForEditOutput> GetPersonForEditAsync(NullableIdDto input) { var output = new GetPersonForEditOutput(); PersonEditDto personEditDto; if (input.Id.HasValue) { var entity = await _personRepository.GetAsync(input.Id.Value); //改造 var entity2 = await _personRepository.GetAllIncluding(a => a.PhoneNumbers).FirstOrDefaultAsync(a => a.Id == input.Id.Value); personEditDto = entity.MapTo <PersonEditDto>(); } else { personEditDto = new PersonEditDto(); } output.Person = personEditDto; return(output); }
public async Task <PartialViewResult> CreateOrEditModal(int?id) { GetPersonForEditOutput getPersonForEditOutput; if (id.HasValue) { getPersonForEditOutput = await _personsAppService.GetPersonForEdit(new EntityDto { Id = (int)id }); getPersonForEditOutput.Person.Attachments = await _attachmentFilesAppService.GetAttacments(id + "", AttachmentTypeConsts.IDCardImageID); } else { getPersonForEditOutput = new GetPersonForEditOutput { Person = new CreateOrEditPersonDto() }; } var viewModel = new CreateOrEditPersonModalViewModel() { Person = getPersonForEditOutput.Person, AttachmentType = await _attachmentTypesAppService.GetAttachmentTypeById(AttachmentTypeConsts.IDCardImageID) }; return(PartialView("_CreateOrEditModal", viewModel)); }
public async Task <GetPersonForEditOutput> GetPersonForEdit(EntityDto input) { var person = await _personRepository.FirstOrDefaultAsync(input.Id); var output = new GetPersonForEditOutput { Person = ObjectMapper.Map <CreateOrEditPersonDto>(person) }; return(output); }
/// <summary> /// 获取 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <GetPersonForEditOutput> GetPersonForEditByIdAsync(NullableIdDto input) { var output = new GetPersonForEditOutput(); PersonEditDto personEditDto; if (input.Id.HasValue) { var entity = await _personRepository.GetAsync(input.Id.Value); personEditDto = entity.MapTo <PersonEditDto>(); } else { personEditDto = new PersonEditDto(); } output.Person = personEditDto; return(output); }
/// <summary> /// 导出Person为excel表 /// </summary> /// <returns></returns> //public async Task<FileDto> GetPersonsToExcel(){ //var users = await UserManager.Users.ToListAsync(); //var userListDtos = ObjectMapper.Map<List<UserListDto>>(users); //await FillRoleNames(userListDtos); //return _userListExcelExporter.ExportToFile(userListDtos); //} /// <summary> /// MPA版本才会用到的方法 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <GetPersonForEditOutput> GetPersonForEdit(NullableIdDto <int> input) { var output = new GetPersonForEditOutput(); PersonEditDto personEditDto; if (input.Id.HasValue) { var entity = await _personRepository.GetAsync(input.Id.Value); personEditDto = entity.MapTo <PersonEditDto>(); //personEditDto = ObjectMapper.Map<List <personEditDto>>(entity); } else { personEditDto = new PersonEditDto(); } output.Person = personEditDto; return(output); }
public EditPersonModalViewModel(GetPersonForEditOutput output) { output.MapTo(this); }