using OFBButte.Application.Database; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace OFBButte.Application.Users { public class FederateProfile { private readonly IOFBContext context; public FederateProfile(IOFBContext context) { this.context = context; } public bool Handle(string email, string lastName, string federationCode) { // Get the user var user = context.Users.FirstOrDefault(u => u.Email == email && u.Profile == null); if (user == null) return false; // Get the profile var profile = context.Profiles.FirstOrDefault(p => p.ProfileFederationCode.Code == federationCode && p.LastName == lastName); if (profile == null) return false; user.Profile = profile; context.SaveChanges(); return true; } } }