public async Task <GetMachineForEditOutput> GetMachineForEdit(EntityDto input) { var machine = await _machineRepository.FirstOrDefaultAsync(input.Id); var output = new GetMachineForEditOutput { Machine = ObjectMapper.Map <CreateOrEditMachineDto>(machine) }; return(output); }
public async Task <GetMachineForEditOutput> GetMachineForEdit(EntityDto input) { var machine = await _machineRepository.FirstOrDefaultAsync(input.Id); var output = new GetMachineForEditOutput { Machine = ObjectMapper.Map <CreateOrEditMachineDto>(machine) }; if (output.Machine.OrganizationUnitId != null) { var _lookupOrganizationUnit = await _lookup_organizationUnitRepository.FirstOrDefaultAsync((long)output.Machine.OrganizationUnitId); output.OrganizationUnitDisplayName = _lookupOrganizationUnit.DisplayName.ToString(); } return(output); }
public async Task <PartialViewResult> CreateOrEditModal(int?id) { GetMachineForEditOutput getMachineForEditOutput; if (id.HasValue) { getMachineForEditOutput = await _machinesAppService.GetMachineForEdit(new EntityDto { Id = (int)id }); } else { getMachineForEditOutput = new GetMachineForEditOutput { Machine = new CreateOrEditMachineDto() }; } var viewModel = new CreateOrEditMachineModalViewModel() { Machine = getMachineForEditOutput.Machine, }; return(PartialView("_CreateOrEditModal", viewModel)); }