public void SaveCart(Cart cart) { var existingCart = _reservationsModel.Carts.FirstOrDefault(c => c.SessionId == cart.SessionId); if (existingCart != null) { existingCart._Products = cart._Products; } else { _reservationsModel.Carts.Add(cart); } _reservationsModel.SaveChanges(); }
public void UpdateOrAddSession(string sessionId, bool isLoggedInUser) { Session session = _sessionsModel.Sessions.FirstOrDefault(id => id.SessionId == sessionId); if (session == null) { session = new Session(sessionId, isLoggedInUser); _sessionsModel.Sessions.Add(session); } else { session.LastTimeActive = DateTime.Now; } _sessionsModel.SaveChanges(); }