Esempio n. 1
0
        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"));
            }
        }
Esempio n. 2
0
        public async Task CreateOrUpdateEpidemiologicInfo(EpidemiologicInfoCreateOrUpdateInput input)
        {
            await CheckValidation(input);

            if (input.Id.HasValue)
            {
                await UpdateEpidemiologicInfoAsync(input);
            }
            else
            {
                await CreateEpidemiologicInfoAsync(input);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 private async Task CreateEpidemiologicInfoAsync(EpidemiologicInfoCreateOrUpdateInput input)
 {
     var epidemiologicInfo = ObjectMapper.Map <EpidemiologicInfo>(input);
     await _epidemiologicInfoRepository.InsertAsync(epidemiologicInfo);
 }