Exemple #1
0
 public static string ToString(ParticipantType value)
 {
     if (value == ParticipantType.Admitter)
     {
         return("admitter");
     }
     else if (value == ParticipantType.Discharger)
     {
         return("discharger");
     }
     else if (value == ParticipantType.Responsible)
     {
         return("responsible");
     }
     else if (value == ParticipantType.Attending)
     {
         return("attending");
     }
     else if (value == ParticipantType.Consulting)
     {
         return("consulting");
     }
     else if (value == ParticipantType.Referrer)
     {
         return("referrer");
     }
     else
     {
         throw new ArgumentException("Unrecognized ParticipantType value: " + value.ToString());
     }
 }
        /// <summary>
        /// Base for rendering a participant.
        /// </summary>
        /// <param name="participantType">The type of participant.</param>
        /// <param name="name">The name of the participant.</param>
        /// <param name="color">Optional color of the participant.</param>
        /// <param name="order">Optional order of the participant.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is <c>null</c>, empty of only white space.</exception>
        internal static void ParticipantBase(this StringBuilder stringBuilder, ParticipantType participantType, ParticipantName name, Color color, int?order)
        {
            if (stringBuilder is null)
            {
                throw new ArgumentNullException(nameof(stringBuilder));
            }

            if (participantType >= ParticipantType.Participant)
            {
                stringBuilder.Append(participantType.ToString().ToLowerInvariant());
                stringBuilder.Append(Constant.Space);
            }

            stringBuilder.Append(name);

            if (order.HasValue)
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(Constant.Order);
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(order.Value);
            }

            if (color is not null)
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(color);
            }

            stringBuilder.AppendNewLine();
        }
Exemple #3
0
            public static bool TryParse(string value, out ParticipantType result)
            {
                result = default(ParticipantType);

                if (value == "admitter")
                {
                    result = ParticipantType.Admitter;
                }
                else if (value == "discharger")
                {
                    result = ParticipantType.Discharger;
                }
                else if (value == "responsible")
                {
                    result = ParticipantType.Responsible;
                }
                else if (value == "attending")
                {
                    result = ParticipantType.Attending;
                }
                else if (value == "consulting")
                {
                    result = ParticipantType.Consulting;
                }
                else if (value == "referrer")
                {
                    result = ParticipantType.Referrer;
                }
                else
                {
                    return(false);
                }

                return(true);
            }
Exemple #4
0
        /// <summary>
        /// Generate the necessary parameters
        /// </summary>
        public List <KeyValuePair <string, string> > GetParams()
        {
            var p = new List <KeyValuePair <string, string> >();

            if (ParticipantType != null)
            {
                p.Add(new KeyValuePair <string, string>("ParticipantType", ParticipantType.ToString()));
            }

            if (Identifier != null)
            {
                p.Add(new KeyValuePair <string, string>("Identifier", Identifier));
            }

            if (FriendlyName != null)
            {
                p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName));
            }

            if (ProxyIdentifier != null)
            {
                p.Add(new KeyValuePair <string, string>("ProxyIdentifier", ProxyIdentifier));
            }

            if (ProxyIdentifierSid != null)
            {
                p.Add(new KeyValuePair <string, string>("ProxyIdentifierSid", ProxyIdentifierSid.ToString()));
            }

            return(p);
        }
Exemple #5
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="updater">The user performing the update.</param>
 /// <param name="participantId">The participant id.</param>
 /// <param name="projectId">The project id.</param>
 /// <param name="hostInstitutionId">The host institution id.</param>
 /// <param name="homeInstitutionId">The home institution id.</param>
 /// <param name="hostInstitutionAddressId">The host instutition address id.</param>
 /// <param name="homeInstitutionAddressId">The home institutution address id.</param>
 /// <param name="participantTypeId">The participant type id.</param>
 /// <param name="participantStatusId">The participant status id.</param>
 public UpdatedParticipantPerson(
     User updater,
     int participantId,
     int projectId,
     int?hostInstitutionId,
     int?homeInstitutionId,
     int?hostInstitutionAddressId,
     int?homeInstitutionAddressId,
     int participantTypeId,
     int?participantStatusId,
     int?placementOrganizationId,
     int?placementOrganizationAddressId)
 {
     if (ParticipantType.GetStaticLookup(participantTypeId) == null)
     {
         throw new UnknownStaticLookupException(String.Format("The participant type id [{0}] is not recognized.", participantTypeId));
     }
     if (participantStatusId.HasValue && ParticipantStatus.GetStaticLookup(participantStatusId.Value) == null)
     {
         throw new UnknownStaticLookupException(String.Format("The participant status id [{0}] is not recognized.", participantStatusId));
     }
     this.Audit                          = new Update(updater);
     this.ProjectId                      = projectId;
     this.ParticipantId                  = participantId;
     this.HostInstitutionId              = hostInstitutionId;
     this.HostInstitutionAddressId       = hostInstitutionAddressId;
     this.HomeInstitutionAddressId       = homeInstitutionAddressId;
     this.HomeInstitutionId              = homeInstitutionId;
     this.ParticipantTypeId              = participantTypeId;
     this.ParticipantStatusId            = participantStatusId;
     this.PlacementOrganizationId        = placementOrganizationId;
     this.PlacementOrganizationAddressId = placementOrganizationAddressId;
 }
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] ParticipantType participantType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != participantType.Id)
            {
                return(BadRequest());
            }

            participantType.ModifiedUserId = Convert.ToInt32(((ClaimsIdentity)HttpContext.User.Identity).FindFirst(ClaimTypes.Sid).Value);
            participantType.ModifiedDate   = DateTime.Now;

            _context.Entry(participantType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(participantType));
        }
Exemple #7
0
        public async Task TestGet_CheckProperties()
        {
            var participantType = new ParticipantType
            {
                Name = ParticipantType.ForeignNonTravelingParticipant.Value,
                ParticipantTypeId = ParticipantType.ForeignNonTravelingParticipant.Id
            };

            context.ParticipantTypes.Add(participantType);
            Action <PagedQueryResults <ParticipantTypeDTO> > tester = (results) =>
            {
                Assert.AreEqual(1, results.Total);
                Assert.AreEqual(1, results.Results.Count);

                var firstResult = results.Results.First();
                Assert.AreEqual(participantType.ParticipantTypeId, firstResult.Id);
                Assert.AreEqual(participantType.Name, firstResult.Name);
            };
            var defaultSorter = new ExpressionSorter <ParticipantTypeDTO>(x => x.Id, SortDirection.Ascending);
            var queryOperator = new QueryableOperator <ParticipantTypeDTO>(0, 10, defaultSorter);

            var serviceResults      = service.Get(queryOperator);
            var serviceResultsAsync = await service.GetAsync(queryOperator);

            tester(serviceResults);
            tester(serviceResultsAsync);
        }
Exemple #8
0
        public void TestConstructor()
        {
            var participantType = new ParticipantType();
            var instance        = new UpdatedParticipantPersonValidationEntity(participantType);

            Assert.IsTrue(object.ReferenceEquals(participantType, instance.ParticipantType));
        }
        public void TestCreateGetParticipantPersonsSevisDTOByIdQuery_ParticipantIsNotAPerson()
        {
            var status = new ParticipantStatus
            {
                ParticipantStatusId = 1,
                Status = "status",
            };
            var participantType = new ParticipantType
            {
                IsPerson          = true,
                Name              = "part type",
                ParticipantTypeId = 90
            };
            var participant = new Participant
            {
                ParticipantId       = 1,
                Status              = status,
                ParticipantStatusId = status.ParticipantStatusId,
                ProjectId           = 250,
                ParticipantTypeId   = participantType.ParticipantTypeId,
                ParticipantType     = participantType,
            };

            context.ParticipantTypes.Add(participantType);
            context.ParticipantStatuses.Add(status);
            context.Participants.Add(participant);

            var results = ParticipantPersonsSevisQueries.CreateGetParticipantPersonsSevisDTOByIdQuery(context, participant.ProjectId, participant.ParticipantId).ToList();

            Assert.AreEqual(0, results.Count());
        }
        public void TestCreateGetParticipantDTOByIdQuery()
        {
            var status = new ParticipantStatus
            {
                ParticipantStatusId = 1,
                Status = "status",
            };
            var person = new Person
            {
                PersonId = 1,
                FullName = "firstName lastName"
            };

            var history = new History
            {
                RevisedOn = DateTimeOffset.Now
            };

            var participantType = new ParticipantType
            {
                ParticipantTypeId = ParticipantType.Individual.Id,
                Name     = "name",
                IsPerson = true
            };

            var participant = new Participant
            {
                ParticipantId       = 1,
                PersonId            = person.PersonId,
                Person              = person,
                ParticipantType     = participantType,
                ParticipantTypeId   = participantType.ParticipantTypeId,
                History             = history,
                Status              = status,
                ParticipantStatusId = status.ParticipantStatusId
            };

            participant.Status = status;
            status.Participants.Add(participant);

            context.ParticipantStatuses.Add(status);
            context.People.Add(person);
            context.ParticipantTypes.Add(participantType);
            context.Participants.Add(participant);
            var results = ParticipantQueries.CreateGetParticipantDTOByIdQuery(context, participant.ParticipantId);

            Assert.AreEqual(1, results.Count());
            var result = results.First();

            Assert.AreEqual(participant.ParticipantId, result.ParticipantId);
            Assert.AreEqual(participant.PersonId, result.PersonId);
            Assert.IsNull(participant.OrganizationId);
            Assert.AreEqual(participant.ParticipantTypeId, result.ParticipantTypeId);
            Assert.AreEqual(participant.ParticipantType.Name, result.ParticipantType);
            Assert.AreEqual(person.FullName, result.Name);
            Assert.AreEqual(status.Status, result.ParticipantStatus);
            Assert.AreEqual(status.ParticipantStatusId, result.StatusId);
            Assert.AreEqual(history.RevisedOn, result.RevisedOn);
            Assert.AreEqual(participantType.IsPerson, result.IsPersonParticipantType);
        }
 public ParticipantExtrinsicState(string name, ParticipantType partType)
 {
     Name     = name;
     PartType = partType;
     Mode     = ParticipantMode.idle;
     X        = 0;
     Y        = 0;
 }
        public Tuple <ParticipantImproved, ParticipantExtrinsicState> Create()
        {
            ParticipantType           type = GenerateType();
            ParticipantImproved       pi   = CreateParticipant(type);
            ParticipantExtrinsicState ps   = CreateParticipantExtrinsicState(type);

            return(new Tuple <ParticipantImproved, ParticipantExtrinsicState>(pi, ps));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ParticipantType participantType = db.ParticipantTypes.Find(id);

            db.ParticipantTypes.Remove(participantType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void TestCreateGetOrganizationParticipantsQuery_HasPrimaryAddress()
        {
            var participantType = new ParticipantType
            {
                Name = ParticipantType.ForeignNonTravelingParticipant.Value,
                ParticipantTypeId = ParticipantType.ForeignNonTravelingParticipant.Id,
            };
            var organization = new Organization
            {
                OrganizationId = 1,
                Name           = "org name"
            };

            var participant = new Participant
            {
                Organization      = organization,
                OrganizationId    = organization.OrganizationId,
                ParticipantType   = participantType,
                ParticipantTypeId = participantType.ParticipantTypeId
            };
            var address = new Address
            {
                IsPrimary = true,
                Location  = new Location
                {
                    City = new Location
                    {
                        LocationName = "city"
                    },
                    Country = new Location
                    {
                        LocationName = "country"
                    }
                }
            };

            organization.Addresses.Add(address);
            context.Addresses.Add(address);
            context.Locations.Add(address.Location);
            context.Locations.Add(address.Location.Country);
            context.ParticipantTypes.Add(participantType);
            context.Organizations.Add(organization);
            context.Participants.Add(participant);


            var results = ParticipantQueries.CreateGetOrganizationParticipantsQuery(context);

            Assert.AreEqual(1, results.Count());
            var participantResult = results.First();

            //Assert all org properties are null
            Assert.IsFalse(participantResult.PersonId.HasValue);
            Assert.AreEqual(participantType.ParticipantTypeId, participantResult.ParticipantTypeId);
            Assert.AreEqual(participantType.Name, participantResult.ParticipantType);
            Assert.AreEqual(organization.Name, participantResult.Name);
            Assert.AreEqual(address.Location.City.LocationName, participantResult.City);
            Assert.AreEqual(address.Location.Country.LocationName, participantResult.Country);
        }
        public void TestCreateGetParticipantPersonsSevisDTOByIdQuery()
        {
            var person = new Person
            {
                PersonId = 1,
                FullName = "full name"
            };
            var status = new ParticipantStatus
            {
                ParticipantStatusId = 1,
                Status = "status",
            };
            var participantType = new ParticipantType
            {
                IsPerson          = true,
                Name              = "part type",
                ParticipantTypeId = 90
            };
            var participant = new Participant
            {
                ParticipantId       = 1,
                Status              = status,
                ParticipantStatusId = status.ParticipantStatusId,
                ProjectId           = 250,
                ParticipantTypeId   = participantType.ParticipantTypeId,
                ParticipantType     = participantType,
                Person              = person,
                PersonId            = person.PersonId
            };

            var participantPerson = new ParticipantPerson
            {
                ParticipantId          = participant.ParticipantId,
                Participant            = participant,
                EndDate                = DateTimeOffset.UtcNow.AddDays(10.0),
                IsCancelled            = true,
                IsDS2019Printed        = true,
                IsDS2019SentToTraveler = true,
                IsSentToSevisViaRTI    = true,
                IsValidatedViaRTI      = true,
                SevisBatchResult       = "sevis batch result",
                SevisId                = "sevis id",
                SevisValidationResult  = "sevis validation result",
                StartDate              = DateTimeOffset.UtcNow.AddDays(-10.0)
            };

            participant.ParticipantPerson = participantPerson;

            context.People.Add(person);
            context.ParticipantTypes.Add(participantType);
            context.ParticipantStatuses.Add(status);
            context.Participants.Add(participant);
            context.ParticipantPersons.Add(participantPerson);

            var results = ParticipantPersonsSevisQueries.CreateGetParticipantPersonsSevisDTOByIdQuery(context, participant.ProjectId, participant.ParticipantId).ToList();

            Assert.AreEqual(1, results.Count());
        }
Exemple #16
0
 public Participant(string name, ParticipantType partType)
 {
     Name                = name;
     PartType            = partType;
     AnimationBinaryData = AnimationInfoDatabase.GetAnimationBinaryData(PartType);
     Mode                = ParticipantMode.idle;
     X = 0;
     Y = 0;
 }
 public ActionResult Edit(ParticipantType item)
 {
     if (ModelState.IsValid)
     {
         CH.Edit <ParticipantType>(item);
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
Exemple #18
0
 /// <summary>
 /// Updates the given participant with the AdditionalProjectParticipant details.
 /// </summary>
 /// <param name="participant">The participant that is being created.</param>
 /// <param name="participantType">The participant type.</param>
 public void UpdateParticipant(Participant participant, ParticipantType participantType, VisitorType visitorType, DefaultExchangeVisitorFunding defaultExchangeVisitorFunding)
 {
     Contract.Requires(participant != null, "The participant must not be null.");
     Contract.Requires(participantType != null, "The participant type must not be null.");
     participant.ProjectId           = this.ProjectId;
     participant.ParticipantStatusId = this.ParticipantStatusId;
     participant.ParticipantTypeId   = participantType.ParticipantTypeId;
     UpdateParticipantDetails(participant, visitorType, defaultExchangeVisitorFunding);
 }
        public string AddParticipantType(string participantTypeDescription, int admin)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    if (participantTypeDescription == "" || participantTypeDescription == null)
                    {
                        throw new Exception("Please enter a Participant Type Description");
                    }
                    //add check for pre-use
                    var participantTypeList = from x in context.ParticipantTypes
                                              where x.participant_description.ToLower().Equals(participantTypeDescription.ToLower()) && !x.archived_yn
                                              select new ParticipantTypePOCO()
                    {
                        participantTypeDescription = x.participant_description
                    };


                    var GoneparticipantTypeList = from x in context.ParticipantTypes
                                                  where x.participant_description.ToLower().Equals(participantTypeDescription.ToLower()) && x.archived_yn
                                                  select new ParticipantTypePOCO()
                    {
                        participantTypeDescription = x.participant_description
                    };
                    if (participantTypeList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The participant type \"" + participantTypeDescription.ToLower() + "\" already exists. Please enter a new participant type.");
                    }
                    else if (GoneparticipantTypeList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The participant type \"" + participantTypeDescription.ToLower() + "\" already exists and is Archived. Please enter a new participant type.");
                    }

                    else
                    {
                        ParticipantType pt2 = new ParticipantType();
                        pt2.participant_description  = participantTypeDescription;
                        pt2.administrator_account_id = admin;
                        pt2.date_modified            = DateTime.Now;
                        pt2.archived_yn = false;
                        context.ParticipantTypes.Add(pt2);
                        context.SaveChanges();
                        return("Participant Type " + participantTypeDescription + " added.");
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
        public static int[] GetAnimationBinaryData(ParticipantType pType)
        {
            int[] data = new int[AnimationDataSize];
            for (int i = 0; i < AnimationDataSize; i++)
            {
                data[i] = _rng.Next();
            }

            return(data);
        }
 public ActionResult Edit([Bind(Include = "pTypeID,pTypeName")] ParticipantType participantType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(participantType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(participantType));
 }
Exemple #22
0
        static void Generate1(synapse_client <data_processors.waypoints> client, string source, uint yy, uint mm, uint dd)
        {
            var contests = new ContestsType();

            var contest = new ContestType();

            contest.set_competition("Australian Racing");
            contest.set_contestNumber(1);
            contest.set_contestName(new TextType()).set_Value("Drink XXXX Responsibly Sprint");
            contest.set_sportCode(SportEnum.SportEnum_gp);
            contest.set_datasource(source);
            contest.set_startDate(new DateType()).set_Value(utils.EncodeDate(yy, mm, dd));
            ////
            var participant = new ParticipantType();

            participant.set_number("1");
            participant.set_barrier(new IntegerType()).set_Value(3);
            var entities = new EntitiesType();
            var horse    = entities.set_horse_element("horse", new HorseType());

            horse.set_name("Small Runner");
            horse.set_countryBorn(new TextType()).set_Value("AUS");
            var jockey = entities.set_jockey_element("jockey", new PersonType());

            jockey.set_name("S Clipperton");
            jockey.set_sid("S Clipperton");
            participant.set_entities(entities);
            contest.set_participants_element("1", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("1A");
            participant.set_barrier(new IntegerType()).set_Value(2);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Medium Runner");
            participant.set_entities(entities);
            contest.set_participants_element("1A", participant);
            ////
            participant = new ParticipantType();
            participant.set_number("2");
            participant.set_barrier(new IntegerType()).set_Value(1);
            entities = new EntitiesType();
            entities.set_horse_element("horse", new HorseType()).set_name("Large Runner");
            participant.set_entities(entities);
            contest.set_participants_element("2", participant);
            //
            contests.set_contest_element(source + "|" + yy.ToString() + mm.ToString() + dd.ToString() + ";1000001", contest);

            var waypoints = new waypoints();
            var waypoint  = new waypoint();

            waypoint.set_timestamp(data_processors.federated_serialisation.utils.EncodeDateTime(DateTime.UtcNow));
            waypoint.set_tag("contests_1.example.csharp.1");
            waypoints.add_path_element(waypoint);
            client.publish("test." + source, contests, waypoints, false);
        }
        public ActionResult Create([Bind(Include = "pTypeID,pTypeName")] ParticipantType participantType)
        {
            if (ModelState.IsValid)
            {
                db.ParticipantTypes.Add(participantType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(participantType));
        }
        public ParticipantImproved CreateParticipant(ParticipantType type)
        {
            if (!_sharedParticipants.ContainsKey(type))
            {
                _sharedParticipants.Add(type, new ParticipantImproved(new ParticipantIntrinsicState(type)));
            }

            ParticipantImproved p = _sharedParticipants[type];

            return(p);
        }
 public void Update(ParticipantType _item)
 {
     using (WACDataClassesDataContext wac = new WACDataClassesDataContext())
     {
         //var x = wac.ParticipantType.Where(w => w.pk_ParticipantType == _item.pk_ParticipantType).Select(s => s).Single();
         //x.fk_statusEasement_code = _item.fk_statusEasement_code;
         //x.date = (DateTime)_item.date;
         //x.note = _item.note;
         //wac.SubmitChanges();
     }
     _item = null;
 }
Exemple #26
0
 public ParticipantStateChangeEventArgs(string SessionHandle, int StatusCode, string StatusString,
                                        ParticipantState State, string ParticipantURI, string AccountName,
                                        string DisplayName, ParticipantType ParticipantType)
 {
     this.SessionHandle = SessionHandle;
     this.StatusCode    = StatusCode;
     this.StatusString  = StatusString;
     this.State         = State;
     this.URI           = ParticipantURI;
     this.AccountName   = AccountName;
     this.DisplayName   = DisplayName;
     this.Type          = ParticipantType;
 }
        public ActionResult Create(ParticipantType participant)
        {
            bool result = ParticipantTypeHelper.SaveParticipantType(participant);

            if (result)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["msg"] = "<script>alert('Failed to insert data');</script>";
                return(View());
            }
        }
        // GET: ParticipantTypes/Edit/5
        /// <summary>
        /// Widok edycji typu uczestnictwa.
        /// </summary>
        /// <param name="id">ID typu uczestnictwa.</param>
        /// <returns>Widok z modelem typu uczestnictwa.</returns>
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ParticipantType participantType = db.ParticipantTypes.Find(id);

            if (participantType == null)
            {
                return(HttpNotFound());
            }
            return(View(participantType));
        }
 public Participant(String deviceID, ParticipantType type, ParticipantGroup group, String firstName, String lastName)
 {
     this.participantID = -1;
     this.deviceID = deviceID;
     this.type = type;
     this.group = group;
     this.linkedUser = null;
     this.attended = false;
     this.firstName = firstName;
     this.lastName = lastName;
     this.isTestParticipant = false;
     this.entity = null;
     this.votingWeight = 1;
 }
        public void TestCreateGetPersonParticipantsQuery_CheckProperties_AddressIsNull()
        {
            var participantType = new ParticipantType
            {
                Name = ParticipantType.Individual.Value,
                ParticipantTypeId = ParticipantType.Individual.Id,
            };
            var gender = new Gender
            {
                GenderId   = Gender.Male.Id,
                GenderName = Gender.Male.Value
            };
            var person = new Person
            {
                PersonId  = 1,
                Gender    = gender,
                GenderId  = gender.GenderId,
                FirstName = "first",
                LastName  = "last",
                FullName  = "full name"
            };

            var participant = new Participant
            {
                Person            = person,
                PersonId          = person.PersonId,
                ParticipantType   = participantType,
                ParticipantTypeId = participantType.ParticipantTypeId
            };

            context.ParticipantTypes.Add(participantType);
            context.Genders.Add(gender);
            context.People.Add(person);
            context.Participants.Add(participant);

            var results = ParticipantQueries.CreateGetPersonParticipantsQuery(context);

            Assert.AreEqual(1, results.Count());
            var participantResult = results.First();

            //Assert all org properties are null
            Assert.IsFalse(participantResult.OrganizationId.HasValue);

            Assert.AreEqual(participantType.ParticipantTypeId, participantResult.ParticipantTypeId);
            Assert.AreEqual(participantType.Name, participantResult.ParticipantType);
            Assert.AreEqual(person.PersonId, participantResult.PersonId);
            Assert.AreEqual(person.FullName, participantResult.Name);
            Assert.IsNull(participantResult.Country);
            Assert.IsNull(participantResult.City);
        }
Exemple #31
0
        /// <summary>
        /// Creates a new AdditionalProjectParticipant with the project owner that is adding the participant
        /// and the project id.
        /// </summary>
        /// <param name="projectOwner">The user adding the participant.</param>
        /// <param name="projectId">The project id.</param>
        /// <param name="participantTypeId">The participant type id.</param>
        public AdditionalProjectParticipant(User projectOwner, int projectId, int participantTypeId)
        {
            Contract.Requires(projectOwner != null, "The project owner must not be null.");
            this.Audit               = new Create(projectOwner);
            this.ProjectId           = projectId;
            this.ParticipantStatusId = ParticipantStatus.Active.Id;
            var participantType = ParticipantType.GetStaticLookup(participantTypeId);

            if (participantType == null)
            {
                throw new UnknownStaticLookupException(String.Format("The participant type with id [{0}] is not recognized.", participantTypeId));
            }
            this.ParticipantTypeId = participantTypeId;
        }
            public static bool TryParse(string value, out ParticipantType result)
            {
                result = default(ParticipantType);

                if( value=="admitter")
                    result = ParticipantType.Admitter;
                else if( value=="discharger")
                    result = ParticipantType.Discharger;
                else if( value=="responsible")
                    result = ParticipantType.Responsible;
                else if( value=="attending")
                    result = ParticipantType.Attending;
                else if( value=="consulting")
                    result = ParticipantType.Consulting;
                else if( value=="referrer")
                    result = ParticipantType.Referrer;
                else
                    return false;

                return true;
            }
 public static string ToString(ParticipantType value)
 {
     if( value==ParticipantType.Admitter )
         return "admitter";
     else if( value==ParticipantType.Discharger )
         return "discharger";
     else if( value==ParticipantType.Responsible )
         return "responsible";
     else if( value==ParticipantType.Attending )
         return "attending";
     else if( value==ParticipantType.Consulting )
         return "consulting";
     else if( value==ParticipantType.Referrer )
         return "referrer";
     else
         throw new ArgumentException("Unrecognized ParticipantType value: " + value.ToString());
 }
 public ParticipantStateChangeEventArgs(string SessionHandle, int StatusCode, string StatusString,
     ParticipantState State, string ParticipantURI, string AccountName,
     string DisplayName, ParticipantType ParticipantType)
 {
     this.SessionHandle = SessionHandle;
     this.StatusCode = StatusCode;
     this.StatusString = StatusString;
     this.State = State;
     this.URI = ParticipantURI;
     this.AccountName = AccountName;
     this.DisplayName = DisplayName;
     this.Type = ParticipantType;
 }
 public ParticipantAddedEventArgs(
         string SessionGroupHandle,
         string SessionHandle,
         string ParticipantUri,
         string AccountName,
         string DisplayName,
         ParticipantType type,
         string Application)
 {
     this.SessionGroupHandle = SessionGroupHandle;
     this.SessionHandle = SessionHandle;
     this.URI = ParticipantUri;
     this.AccountName = AccountName;
     this.DisplayName = DisplayName;
     this.Type = type;
     this.Appllication = Application;
 }