public async Task CreateOrUpdateOpportunitySource(OpportunitySourceInput input) { if (input.Id != 0) { await UpdateOpportunitySource(input); } else { await CreateOpportunitySource(input); } }
public async Task CreateOpportunitySource(OpportunitySourceInput input) { var Source = input.MapTo <OpportunitySource>(); var val = _opportunitySourceRepository .GetAll().Where(p => p.Code == input.Code || p.Name == input.Name).FirstOrDefault(); if (val == null) { await _opportunitySourceRepository.InsertAsync(Source); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in Code '" + input.Code + "' orName '" + input.Name + "'..."); } }