public async Task CreateOrUpdateEmaildomain(CreateEmaildomainInput input) { if (input.Id != 0) { await UpdateEmaildomainAsync(input); } else { await CreateEmaildomainAsync(input); } }
public virtual async Task CreateEmaildomainAsync(CreateEmaildomainInput input) { var emaildomain = input.MapTo <Emaildomain>(); var val = _emaildomainRepository .GetAll().Where(p => p.EmaildomainName == input.EmaildomainName).FirstOrDefault(); if (val == null) { await _emaildomainRepository.InsertAsync(emaildomain); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Emaildomain Name '" + input.EmaildomainName + "'..."); } }
public virtual async Task UpdateEmaildomainAsync(CreateEmaildomainInput input) { var emaildomain = await _emaildomainRepository.GetAsync(input.Id); ObjectMapper.Map(input, emaildomain); var val = _emaildomainRepository .GetAll().Where(p => (p.EmaildomainName == input.EmaildomainName) && p.Id != input.Id).FirstOrDefault(); if (val == null) { await _emaildomainRepository.UpdateAsync(emaildomain); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Emaildomain Name '" + input.EmaildomainName + "'..."); } }