41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
namespace TIAM.Database.DbSets.ServiceProvider;
|
|
|
|
//public static class CompanyDbSetExtensions
|
|
//{
|
|
// #region Add, Update, Remove
|
|
|
|
// public static bool AddServiceProvider(this ICompanyDbSet ctx, Company company)
|
|
// {
|
|
// var companyProfile = company.Profile;
|
|
|
|
// if (company.ProfileId.IsNullOrEmpty() || companyProfile.Id != company.ProfileId || companyProfile.AddressId.IsNullOrEmpty() || companyProfile.Address.Id != companyProfile.AddressId)
|
|
// {
|
|
// return false;
|
|
// }
|
|
|
|
// if (!company.OwnerId.IsNullOrEmpty())
|
|
// company.AddUser(company.OwnerId.Value, 1);
|
|
|
|
// return ctx.Companies.Add(company).State == EntityState.Added;
|
|
// }
|
|
|
|
// public static bool RemoveServiceProvider(this ICompanyDbSet ctx, Company company)
|
|
// => ctx.Companies.Remove(company).State == EntityState.Deleted;
|
|
|
|
// public static bool RemoveServiceProvider(this ICompanyDbSet ctx, Guid companyId)
|
|
// {
|
|
// var company = ctx.GetServiceProviderById(companyId);
|
|
// return company == null || ctx.RemoveServiceProvider(company);
|
|
// }
|
|
|
|
// #endregion Add, Update, Remove
|
|
|
|
// public static Company? GetServiceProviderById(this ICompanyDbSet ctx, Guid companyId)
|
|
// => ctx.Companies.FirstOrDefault(x => x.Id == companyId);
|
|
|
|
// public static IQueryable<Company> GetServiceProviders(this ICompanyDbSet ctx)
|
|
// => ctx.Companies;
|
|
|
|
// public static List<Company> GetServiceProvidersByOwnerId(this ICompanyDbSet ctx, Guid ownerId)
|
|
// => ctx.Companies.Where(x => x.OwnerId == ownerId).ToList();
|
|
//} |