Skip to content

Commit

Permalink
CreateOrGetVendor Added
Browse files Browse the repository at this point in the history
  • Loading branch information
semalaiappan committed Feb 27, 2024
1 parent 56b9901 commit 8fdc5c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Application/EdFi.Admin.DataAccess/Repositories/ClientAppRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,24 @@ public void SetDefaultVendorOnUserFromEmailAndName(string userEmail, string user
}
}

public Vendor CreateOrGetVendor(string userEmail, string userName, IEnumerable<string> namespacePrefixes)
{
var vendorName = userName.Split(',')[0]
.Trim();

using (var context = _contextFactory.CreateContext())
{
var vendor = context.Vendors.SingleOrDefault(v => v.VendorName == vendorName);

if (vendor == null)
{
vendor = Vendor.Create(vendorName, namespacePrefixes);
context.SaveChanges();
}
return vendor;
}
}

public Vendor CreateOrGetVendor(string vendorName, IEnumerable<string> namespacePrefixes)
{
string name = vendorName.Split(',')[0].Trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ ApiClient SetupDefaultSandboxClient(string name, SandboxType sandboxType, string
void SetupKeySecret(string name, SandboxType sandboxType, string key, string secret, int userId,
int applicationId);

Vendor CreateOrGetVendor(string userEmail, string userName, IEnumerable<string> namespacePrefixes);

Vendor CreateOrGetVendor(string vendorName, IEnumerable<string> namespacePrefixes);

Application CreateOrGetApplication(int vendorId, string applicationName, long educationOrganizationId);
Expand Down

0 comments on commit 8fdc5c2

Please sign in to comment.