public void Add(UserSession userSession) { using (FondMcfoContext db = new FondMcfoContext()) { db.UserSessions.Add(userSession); db.SaveChanges(); } }}
public void AddSession(string domainName, UserSession sessions) { using (FondMcfoContext db = new FondMcfoContext()) { User user = db.Users.FirstOrDefault(u => u.DomainName == domainName); if (user != null) { user.UserSessionses.Add(sessions); db.SaveChanges(); } } }
public User ManageStartSessions() { var actionsUser = new UserActions(); if (actionsUser.Find(_domainName) != null) { var session = new UserSession{ DateStart = DateTime.Now, IdSessionAplication = _idSessionsApplication }; actionsUser.AddSession(_domainName, session); return actionsUser.Find(_domainName); } else { var seacher = new UserSeacher(_domainName); var userNew = new User {DomainName = _domainName,RegistrationDate = DateTime.Now,Fio = seacher.GetFIOUser() }; var sessionsNew = new UserSession { DateStart = DateTime.Now, Users = userNew}; var actionsUserSession = new UserSessionAction(); actionsUserSession.Add(sessionsNew); return userNew; } }