public async Task CreateProviderAsync(ProviderDto provider, Phone phone, Address address) { try { var dbPhone = await CreatePhone(phone); var addressId = await CreateAddress(address); var user = await DbContext.GetUserByEmailAsync(provider.Email); var dbProvider = new Provider { DateOfBirth = provider.DateOfBirth, Specialty = provider.Specialty, Sex = provider.Sex, LicenseNumber = provider.LicenseNumber, AddressId = addressId, Address = address, Phone = new List<Phone> { dbPhone }, User = user, UserId = user?.Id, }; await DbContext.CreateProviderAsync(dbProvider); } catch (DbEntityValidationException ex) { } }
public async Task CreateProviderAsync(Provider provider) { Providers.AddOrUpdate(provider); await SaveChangesAsync(); }