public static void CheckForAll(string email) { using (var db = new LanguageExchangeModel()) { var user = db.UserAccounts.Where(u => u.UserEmail == email).FirstOrDefault(); if (user == null) { return; } var userId = user.UserIdNumber; var pref = db.UserPreferences.Where(i => i.UserId == userId).FirstOrDefault(); if (pref == null) { pref = new UserPreferences(); pref.UserPreferencesName = user.UserFirstName + " " + user.UserLastName; pref.UserId = userId; pref.UserDescription = "Something interesting about me!"; pref.LastLogin = DateTime.Now; db.UserPreferences.Add(pref); } var calendar = db.AppointmentCalendars.Where(c => c.UserId == userId).FirstOrDefault(); if (calendar == null) { calendar = new AppointmentCalendar(); calendar.UserId = userId; db.AppointmentCalendars.Add(calendar); } var inbox = db.EmailInboxes.Where(i => i.UserId == userId).FirstOrDefault(); if (inbox == null) { inbox = new EmailInbox(); inbox.UserId = userId; db.EmailInboxes.Add(inbox); } var tracking = db.UserTrackingDetails.Where(t => t.UserId == userId).FirstOrDefault(); if (tracking == null) { tracking = new UserTrackingDetails(); tracking.UserId = userId; db.UserTrackingDetails.Add(tracking); } db.SaveChanges(); } }
public static AppointmentCalendar ShowAppointmentCalendar(string email) { var db = new LanguageExchangeModel(); var user = db.UserAccounts.Where(u => u.UserEmail == email).FirstOrDefault(); var userId = user.UserIdNumber; var calendar = db.AppointmentCalendars.Where(c => c.UserId == userId).FirstOrDefault(); if (calendar == null) { calendar = new AppointmentCalendar(); calendar.UserId = userId; db.AppointmentCalendars.Add(calendar); db.SaveChanges(); } return calendar; }