public async Task CreateOrUpdateService(CreateServiceInput input) { if (input.Id != 0) { await UpdateService(input); } else { await CreateService(input); } }
public async Task CreateService(CreateServiceInput input) { input.TenantId = (int)_session.TenantId; var service = input.MapTo <Service>(); var val = _ServiceRepository .GetAll().Where(p => p.ServiceCode == input.ServiceCode || p.ServiceName == input.ServiceName).FirstOrDefault(); if (val == null) { await _ServiceRepository.InsertAsync(service); } else { throw new UserFriendlyException("Ooops!", "Duplicate Data Occured in ServiceCode '" + input.ServiceCode + "' or ServiceName '" + input.ServiceName + "'..."); } }