private async Task CheckValidation(EpidemiologicInfoCreateOrUpdateInput input) { var existingObj = (await _epidemiologicInfoRepository.GetAll().AsNoTracking() .FirstOrDefaultAsync(l => l.Code == input.Code)); if (existingObj != null && existingObj.Id != input.Id) { throw new UserFriendlyException(L("ThisCodeAlreadyExists")); } }
public async Task CreateOrUpdateEpidemiologicInfo(EpidemiologicInfoCreateOrUpdateInput input) { await CheckValidation(input); if (input.Id.HasValue) { await UpdateEpidemiologicInfoAsync(input); } else { await CreateEpidemiologicInfoAsync(input); } }
public async Task <EpidemiologicInfoCreateOrUpdateInput> GetEpidemiologicInfoForEdit(NullableIdDto <int> input) { //Getting all available roles var output = new EpidemiologicInfoCreateOrUpdateInput(); if (input.Id.HasValue) { //Editing an existing user var epidemiologicInfo = await _epidemiologicInfoRepository.GetAsync(input.Id.Value); if (epidemiologicInfo != null) { ObjectMapper.Map <EpidemiologicInfo, EpidemiologicInfoCreateOrUpdateInput>(epidemiologicInfo, output); } } return(output); }
private async Task CreateEpidemiologicInfoAsync(EpidemiologicInfoCreateOrUpdateInput input) { var epidemiologicInfo = ObjectMapper.Map <EpidemiologicInfo>(input); await _epidemiologicInfoRepository.InsertAsync(epidemiologicInfo); }