Ejemplo n.º 1
0
        public ActionResult AssignBeneficiaryToSession(int Beneficiary, int Session, bool Attended, bool Completed)
        {
            if (ModelState.IsValid)
            {
                //Beneficiary objClass = db.Beneficiaries.Where(x => x.BeneficiaryID == Beneficiary).FirstOrDefault();
                //Session objSession = db.Sessions.Where(x => x.SessionID == Session).FirstOrDefault();
                //List<Session> objSessions = new List<Session>();
                //objSessions.Add(objSession);
                //objClass.Session = objSessions;
                //db.Entry(objClass).State = EntityState.Modified;
                //db.SaveChanges();

                SessionParticipant ObjSP = new SessionParticipant();
                ObjSP.SessionID = Session;
                ObjSP.BeneficiaryID = Beneficiary;
                ObjSP.Attended = Attended;
                ObjSP.Completed = Completed;
                db.SessionParticipants.Add(ObjSP);
                db.SaveChanges();

                //Beneficiary objClass = db.Beneficiaries.Single(x => x.BeneficiaryID == Beneficiary);
                //Session p = db.Sessions.Single(c => c.SessionID == Session);
                //objClass.Session.Add(p);
                //db.SaveChanges();

                ViewBag.Beneficiary = new SelectList(db.Beneficiaries.ToList(), "BeneficiaryID", "Names");
                ViewBag.Session = new SelectList(db.Sessions.ToList(), "SessionID", "SessionID");
            }
            return View();
        }
Ejemplo n.º 2
0
        public ClientCommunicator()
        {
            this._participant = new UdpParticipant();
            this._participant.ManagerFound += ((sender, e) =>
            {
                // Found a game host.
                this._managerCommunicationChannel = _participant.CreateCommunicationChannel(e.Id);
                this._managerGuid = e.Id;
                this.GameAvailable(this, EventArgs.Empty);
            });


            this._participantCommunicationChannel = new TcpCommunicationChannel();
            this._participantCommunicationChannel.MessageReceived += ((sender, e) =>
            {
                // Decode the message that the game host sent to us.
                string[] message = e.Message.ToString().Split('-');
                switch (message[0])
                {
                case QUESTION_COMMAND:     // The game host sent a question to us.
                    NewQuestionAvailable(this,
                                         new QuestionEventArgs {
                        Question = ParseQuestion(e.Message.ToString())
                    });
                    break;

                case JOIN_COMMAND:     // The game host sent a confirmation that we are connected.
                    this.HostJoinStatusMessageReceived(this,
                                                       new HostJoinStatusMessageReceivedArgs {
                        IsJoined = Boolean.Parse(message[1])
                    });
                    break;
                }
            });
        }
        public static SessionParticipant ConvertToParticipant(ProfileModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var converted = new SessionParticipant()
            {
                Player       = ConvertToPlayer(model),
                CurrentState = SessionParticipant.ParticipantState.Setuping
            };

            return(converted);
        }
Ejemplo n.º 4
0
        public bool UpdateReviewForSessionParticipant(int sessionId, int participantId, int rating, string comments)
        {
            SessionParticipant sessionParticipant = GetASessionParticipant(sessionId, participantId);

            if (sessionParticipant == null)
            {
                return(false);
            }

            sessionParticipant.Rating   = rating;
            sessionParticipant.Comments = comments;
            _db.SaveChanges();

            return(true);
        }
Ejemplo n.º 5
0
        public bool AddParticipantToSession(int participantId, int sessionId)
        {
            if (!CheckIfParticipantExists(participantId) || !CheckIfSessionExists(sessionId) ||
                CheckIfSessionParticipantAlreadyExists(participantId, sessionId))
            {
                return(false);
            }

            var result = new SessionParticipant()
            {
                ParticipantId = participantId,
                SessionId     = sessionId,
                Rating        = 0
            };

            _db.Add <SessionParticipant>(result);
            _db.SaveChanges();

            return(true);
        }
Ejemplo n.º 6
0
        public bool AddExpressionOfInterest(int sessionId, int participantId)
        {
            var theSession = _db.Get <Session>().SingleOrDefault(n => n.Id == sessionId);

            if (theSession == null || !theSession.IsOpenForExpressionOfInterest || theSession.StartDate < DateTime.Now)
            {
                return(false);
            }

            var result = new SessionParticipant()
            {
                ParticipantId = participantId,
                SessionId     = sessionId,
            };

            _db.Add <SessionParticipant>(result);
            _db.SaveChanges();

            return(true);
        }