protected virtual async Task CreateEmployeeAsync(CreateOrUpdateEmployeeInput input) { var emp = ObjectMapper.Map <Employee>(input.Employee); //Passwords is not mapped (see mapping configuration) emp.TenantId = (int)AbpSession.TenantId; await _empRepository.InsertAsync(emp); await CurrentUnitOfWork.SaveChangesAsync(); //return ObjectMapper.Map<TaskListDto>(task); }
/// <summary> /// 添加或者修改Employee的公共方法 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task CreateOrUpdateEmployee(CreateOrUpdateEmployeeInput input) { if (input.Employee.Id != null) { await UpdateEmployeeAsync(input.Employee); } else { await CreateEmployeeAsync(input.Employee); } }
public async Task CreateOrUpdateEmployee(CreateOrUpdateEmployeeInput input) { if (input.Employee.Id.HasValue) { await UpdateEmployeeAsync(input); } else { await CreateEmployeeAsync(input); } }
// /// <summary> // /// 获取编辑 Employee // /// </summary> // /// <param name="input"></param> // /// <returns></returns> // public async Task<GetEmployeeForEditOutput> GetForEditAsync(NullableIdDto<string> input) // { // var output = new GetEmployeeForEditOutput(); //EmployeeEditDto editDto; // if (input.Id.HasValue) // { // var entity = await _entityRepository.GetAsync(input.Id.Value); // editDto = entity.MapTo<EmployeeEditDto>(); // //employeeEditDto = ObjectMapper.Map<List<employeeEditDto>>(entity); // } // else // { // editDto = new EmployeeEditDto(); // } // output.Employee = editDto; // return output; // } /// <summary> /// 添加或者修改Employee的公共方法 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task CreateOrUpdateAsync(CreateOrUpdateEmployeeInput input) { if (String.IsNullOrEmpty(input.Employee.Id)) { await UpdateAsync(input.Employee); } else { await CreateAsync(input.Employee); } }
protected virtual async Task UpdateEmployeeAsync(CreateOrUpdateEmployeeInput input) { Logger.Info("Updating a task for input: " + input); var emp = await _empRepository.FirstOrDefaultAsync(input.Employee.Id.Value); emp.Name = input.Employee.Name; emp.Birthday = input.Employee.Birthday; emp.TenantId = (int)AbpSession.TenantId; await _empRepository.UpdateAsync(emp); await CurrentUnitOfWork.SaveChangesAsync(); if (emp == null) { throw new UserFriendlyException(L("CouldNotFindTheTaskMessage")); } //return ObjectMapper.Map<EmployeeListDto>(emp); }