Exemplo n.º 1
0
        public TreePerson(PersonType Type, string idString = "", Person familySearchPerson = null)
        {
            switch (Type)
            {
                case PersonType.Null:
                    Name = Death = "";
                    Sex = PersonSex.NotSet;
                    Birth = idString;
                    break;

                case PersonType.Unique:
                    var perRandom = StaticRandom.RandomNumber(0, 100);
                    //Debug.WriteLine("Random " + perRandom);
                    if (perRandom > 49)
                    {
                        Sex = PersonSex.Male;
                        Name = MaleNames[StaticRandom.RandomNumber(0, MaleNames.Length)];
                        Birth = idString;
                    }
                    else
                    {
                        Sex = PersonSex.Female;
                        Name = FemaleNames[StaticRandom.RandomNumber(0, FemaleNames.Length)];
                        Birth = idString;
                    }
                    break;

                case PersonType.Adam:
                    Sex = PersonSex.Male;
                    Name = "Adam";
                    Birth = idString;
                    BirthFamilyIndex = 0; // from Generation 0
                    break;

                case PersonType.Eve:
                    Sex = PersonSex.Female;
                    Name = "Eve";
                    Birth = idString;
                    BirthFamilyIndex = 0; // from Generation 0
                    break;

                case PersonType.FamilySearch:
                    if (familySearchPerson != null)
                    {
                        _familSearchPerson = familySearchPerson;

                        // Just the basics of the person are set now
                        Name = familySearchPerson.DisplayExtension.Name;
                        Sex = GetSexEnum(familySearchPerson.DisplayExtension.Gender);                      
                        Birth = familySearchPerson.DisplayExtension.BirthDate ?? "";
                        Death = familySearchPerson.DisplayExtension.DeathDate ?? "";
                        Lifespan = familySearchPerson.DisplayExtension.Lifespan;
                        _familySearchID = familySearchPerson.Id;
                    }

                    break;
            }

            myEvents = new List<FamilyEvent>();
        }
Exemplo n.º 2
0
 public Person(string firstName, string lastName, PersonType personType, int? familyID)
 {
     FirstName = firstName;
     LastName = lastName;
     PersonType = personType;
     FamilyId = familyID;
 }
Exemplo n.º 3
0
 public Person(string firstName, string lastName, PersonType personType, double weight)
 {
     FirstName = firstName;
     LastName = lastName;
     PersonType = personType;
     Weight = weight;
 }
        /// <summary>
        ///     Get Person Name
        /// </summary>
        /// <param name="id"></param>
        /// <param name="personType"></param>
        /// <returns></returns>
        private static string GetPersonName(long id, PersonType personType)
        {
            string personName = string.Empty;

            switch (personType)
            {
                case PersonType.Customer:
                    var customer = CustomerRepository.GetById(id);
                    personName = customer.FullName;
                    break;
                case PersonType.Employee:
                    var employee = EmployeeRepository.GetById(id);
                    personName = employee.FullName;
                    break;
                case PersonType.Manager:
                    var manager = ManagerRepository.GetById(id);
                    personName = manager.FullName;
                    break;
                case PersonType.SalesPerson:
                    var salesPerson = SalesPersonRepository.GetById(id);
                    personName = salesPerson.FullName;
                    break;
            }

            return personName;
        }
 public MorphoSyntacticFeatures(NumberType num, PersonType pers, TenseFormationType tma, TensePositivity posit, TensePassivity voice)
 {
     Number = num;
     Person = pers;
     TenseMoodAspect = tma;
     Positivity = posit;
     Voice = voice;
 }
        /// <summary>
        /// Save parent/child relationship
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="parentPersonType"></param>
        /// <param name="childId"></param>
        /// <param name="childPersonType"></param>
        public void Save(long parentId, PersonType parentPersonType, long childId, PersonType childPersonType)
        {
            var sql = new StringBuilder();

            sql.Append(
                string.Format("SELECT * FROM dbo.RelationshipTree WHERE ParentId = {0} AND ParentPersonType = {1}",
                    parentId, (int)parentPersonType));

            var treeSearcher = AdoProvider.QueryTransaction<Tree>(sql.ToString()).FirstOrDefault();

            var leafs = new List<Leaf>();

            //create new parent / child relationship
            if (treeSearcher == null)
            {
                var leaf = new Leaf { Id = childId, PersonType = childPersonType };
                leafs.Add(leaf);

                sql.Clear();
                sql.Append(
                    "INSERT INTO dbo.RelationshipTree (ParentId, ParentPersonType, ChildBranch, CreatedOn, LastModifiedOn, IsDeleted) ");
                sql.Append(string.Format("VALUES({0}, {1}, '{2}', GETDATE(), GETDATE(), 0)", parentId,
                    (int)parentPersonType,
                    JsonConvert.SerializeObject(leafs)));

                AdoProvider.CommitTransaction(sql.ToString());
            }

            //append child relation to existing child relationships
            if (treeSearcher != null)
            {
                sql.Clear();
                sql.Append(
                    string.Format(
                        "SELECT * FROM dbo.RelationshipTree WHERE ParentId = {0} AND ParentPersonType = {1}",
                        parentId, (int)parentPersonType));

                var childTreeSearcher = AdoProvider.QueryTransaction<Tree>(sql.ToString()).FirstOrDefault();

                if (childTreeSearcher != null)
                {
                    leafs.AddRange(JsonConvert.DeserializeObject<List<Leaf>>(childTreeSearcher.ChildBranch.ToString()));
                }

                var leaf = new Leaf { Id = childId, PersonType = childPersonType };
                leafs.Add(leaf);

                sql.Clear();
                sql.Append("UPDATE dbo.RelationshipTree ");
                sql.Append(string.Format("SET ChildBranch = '{0}', ", JsonConvert.SerializeObject(leafs)));
                sql.Append("LastModifiedOn = GETDATE() ");
                sql.Append(string.Format("WHERE ParentId = {0} AND ParentPersonType = {1}", parentId, (int)parentPersonType));

                AdoProvider.CommitTransaction(sql.ToString());
            }
        }
Exemplo n.º 7
0
 public VerbInflection(Verb vrb, AttachedPronounType zamir,string zamirPeyvastehString, PersonType shakhstype,TenseFormationType tenseFormationType,TensePositivity positivity, TensePassivity passivity)
 {
     VerbRoot = vrb;
     ZamirPeyvasteh = zamir;
     AttachedPronounString = zamirPeyvastehString;
     Person = shakhstype;
     TenseForm = tenseFormationType;
     Positivity = positivity;
     Passivity = passivity;
 }
        public void Delete(long id, PersonType personType)
        {
            var sql = new StringBuilder();

            var parentId = id.ToString(CultureInfo.InvariantCulture);
            var parentPersonTypeId = ((int)personType).ToString(CultureInfo.InvariantCulture);

            sql.Append(string.Format("DELETE FROM RelationshipTree WHERE ParentId = {0} AND ParentPersonType = {1}",
                parentId, parentPersonTypeId));

            AdoProvider.CommitTransaction(sql.ToString());
        }
 public Person addPerson(string lastname, string firstname, PersonType type)
 {
     Person unePersonne = new Person
         {
             Date = DateTime.Now,
             LastName = lastname,
             FirstName = firstname,
             PersonType = type,
             HasSubscribed = false
         };
     _persons.Add(unePersonne);
     return unePersonne;
 }
Exemplo n.º 10
0
 public List<Visit> GetVisits(int personId, PersonType personType, string processCode, DateTime startTime, DateTime endTime)
 {
     return new List<Visit>
     {
         new Visit
         {
             Id = 4,
             Client = (Client)persons.FirstOrDefault(p => p.PersonType == PersonType.Client),
             Employee = (Employee)persons.FirstOrDefault(p => p.PersonType == PersonType.Employee),
             StartTime = new DateTime(2015, 2, 3, 16, 0, 0),
             EndTime = new DateTime(2015, 2, 3, 17, 30, 0)
         }
     };
 }
Exemplo n.º 11
0
        public List<Note> GetPersonNotes(int personId, PersonType personType, int count, int offset, ListSortDirection sortDirection)
        {
            var limit = offset >= 1 ? count : count + offset - 1;
            if (limit < 1)
                return new List<Note>();

            var filtered = notes.Where(p => p.PersonType == personType && p.AuthorId == personId);
            var ordered = sortDirection == ListSortDirection.Ascending
                 ? filtered.OrderBy(n => n.CreatedAt)
                 : filtered.OrderByDescending(n => n.CreatedAt);

            ordered = ordered.ThenBy(x => x.Id);
            var qry = offset > 1 ? ordered.Skip(offset - 1) : ordered;
            return qry.Take(limit).ToList();
        }
        public void Should_Call_TestWithoutParameters(PersonType b)
        {
            // arrange
            const string expectedCode = "testExecutor.Test();";

            _sut.MethodName = "Test";
            _sut.Arguments = new object[0];

            // act
            string code = _sut.CreateCallTestCode("testExecutor");

            // assert
            Assert.That(code, Is.EqualTo(expectedCode));

            Assert.That(b,Is.EqualTo(PersonType.A));
        }
        /// <summary>
        ///     Get entire relationship tree based on Employee, Customer, Manager or SalesPeron Id
        /// </summary>
        /// <param name="id"></param>
        /// <param name="personType"></param>
        /// <returns></returns>
        public IEnumerable<Leaf> GetAll(long id, PersonType personType)
        {
            var sql = new StringBuilder();

            string parentId = id.ToString(CultureInfo.InvariantCulture);
            string personTypeId = ((int)personType).ToString(CultureInfo.InvariantCulture);

            sql.Append(
                string.Format("SELECT * FROM dbo.RelationshipTree WHERE ParentId = {0} AND ParentPersonType = {1}",
                    parentId, personTypeId));

            List<Tree> trees = AdoProvider.QueryTransaction<Tree>(sql.ToString());

            RelationshipBll.TraverseTree(trees);

            return RelationshipBll.RelatedLeafs;
        }
Exemplo n.º 14
0
    public TreePerson(PersonType Type, string birth = "", TreePerson familySearchTreePerson = null)
    {
        switch (Type)
        {
        case PersonType.Null:
            Name = Death = "";
            Sex = PersonSex.NotSet;
            Birth = birth;
            break;

        case PersonType.Unique:
            if (Random.Range(0, 2) == 0)
            {
                Sex = PersonSex.Male;
                Name = MaleNames[Random.Range(0,MaleNames.Length)];
                Birth = birth;
            }
            else
            {
                Sex = PersonSex.Female;
                Name = FemaleNames[Random.Range(0,FemaleNames.Length)];
                Birth = birth;
            }
            break;

        case PersonType.Adam:
            Sex = PersonSex.Male;
            Name = "Adam";
            Birth = birth;
            BirthFamilyIndex = 0;  // from Generation 0
            break;

        case PersonType.Eve:
            Sex = PersonSex.Female;
            Name = "Eve";
            Birth = birth;
            BirthFamilyIndex = 0; // from Generation 0
            break;

            case PersonType.FamilySearch:
                break;
        }

            myEvents = new List<FamilyEvent>();
    }
Exemplo n.º 15
0
        private static Persona CreatePersonaFromDistributionListMember(MailboxSession session, DistributionListMember member, out bool isADMember)
        {
            isADMember = false;
            Participant participant = member.Participant;
            Persona     persona     = new Persona();

            persona.DisplayName               = participant.DisplayName;
            persona.ImAddress                 = participant.GetValueOrDefault <string>(ParticipantSchema.SipUri, null);
            persona.EmailAddress              = new EmailAddressWrapper();
            persona.EmailAddress.RoutingType  = participant.RoutingType;
            persona.EmailAddress.EmailAddress = participant.EmailAddress;
            persona.EmailAddress.Name         = participant.DisplayName;
            StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
            bool       flag       = member.MainEntryId is ADParticipantEntryId;
            PersonType personType = PersonType.Unknown;

            if (storeParticipantOrigin != null)
            {
                personType = ((string.CompareOrdinal(participant.RoutingType, "MAPIPDL") == 0) ? PersonType.DistributionList : PersonType.Person);
                if (session != null)
                {
                    persona.EmailAddress.ItemId = IdConverter.GetItemIdFromStoreId(storeParticipantOrigin.OriginItemId, new MailboxId(session));
                }
                persona.EmailAddress.EmailAddressIndex = storeParticipantOrigin.EmailAddressIndex.ToString();
                if (personType == PersonType.DistributionList)
                {
                    persona.EmailAddress.MailboxType = MailboxHelper.MailboxTypeType.PrivateDL.ToString();
                }
                else if (personType == PersonType.Person)
                {
                    persona.EmailAddress.MailboxType = MailboxHelper.MailboxTypeType.Contact.ToString();
                }
            }
            else if (flag)
            {
                isADMember = true;
            }
            else
            {
                persona.EmailAddress.MailboxType = MailboxHelper.MailboxTypeType.OneOff.ToString();
            }
            persona.PersonaType = PersonaTypeConverter.ToString(personType);
            return(persona);
        }
Exemplo n.º 16
0
        public IActionResult FilterPerson(PersonType type, string name, string phone)
        {
            var           arrNames = !string.IsNullOrEmpty(name) ? name.Split(' ') : null;
            List <Person> persons;

            if (type == PersonType.Representative)
            {
                persons = _personRepository.Representatives.ToList();
            }
            else if (type == PersonType.Customer)
            {
                persons = _personRepository.Customers.ToList();
            }
            else
            {
                persons = _personRepository.Employees.ToList();
            }

            if (!string.IsNullOrEmpty(phone))
            {
                persons = persons.Where(c => c.ContactInfo.Phones.Any(p => !string.IsNullOrEmpty(p.PhoneNumber) && p.PhoneNumber.Contains(phone))).ToList();
            }

            if (arrNames != null)
            {
                var filterName = new List <Person>();
                foreach (var subName in arrNames)
                {
                    var subPerson = persons.Where(c => c.PrimaryName.ToLower().Contains(subName.ToLower())).ToList();
                    if (subPerson.Any())
                    {
                        filterName.AddRange(subPerson.Except(filterName));
                    }
                }

                if (filterName.Any())
                {
                    persons = filterName;
                }
            }

            return(ViewComponent("EmployeeRepresentativeFilter", new { persons }));
        }
Exemplo n.º 17
0
        public void ConfigViaCode()
        {
            //create service stub
            SearchPhoneticClient client = new SearchPhoneticClient(new StsBinding(), new EndpointAddress(new Uri("https://services-acpt.ehealth.fgov.be/consultRN/identifyPerson/v1")));

            client.Endpoint.Behaviors.Remove <ClientCredentials>();
            client.Endpoint.Behaviors.Add(new OptClientCredentials());
            client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "cf692e24bac7c1d990496573e64ef999468be67e");

            //Call with prepared request
            SearchPhoneticReply response = client.Search(request);

            //Verify result
            Assert.AreEqual(response.Status.Message[0].Value, "100", response.Status.Code);
            PersonType bryan = response.Person.Where(p => p.SSIN == "79021802145").Single();

            Assert.AreEqual(bryan.PersonData.Birth.Date, "1979-02-18");
            Assert.AreEqual(bryan.PersonData.Birth.Localisation.Municipality.PostalCode, "8630");
        }
        public static PersonType GetPersonType(this PersonType personType, string status)
        {
            PersonType type = PersonType.Undefined;

            if (status == "Співробітник")
            {
                type = PersonType.Employee;
            }
            else if (status == "Студент")
            {
                type = PersonType.Student;
            }
            else
            {
                type = PersonType.Undefined;
            }

            return(type);
        }
Exemplo n.º 19
0
        public static async Task <Boolean> SavePersonToFile(PersonType person)
        {
            Boolean result     = false;
            string  personData = string.Empty;

            try
            {
                personData = person.ToJson();

                FileSavePicker savePicker = new FileSavePicker();
                savePicker.FileTypeChoices.Add("HROpen Person", new List <string>()
                {
                    ".hrj"
                });
                savePicker.FileTypeChoices.Add("JSON File", new List <string>()
                {
                    ".json"
                });
                savePicker.FileTypeChoices.Add("Text File", new List <string>()
                {
                    ".txt"
                });
                savePicker.DefaultFileExtension = ".hrj";
                savePicker.SuggestedFileName    = person.Name.FormattedName;
                StorageFile itemToSave = await savePicker.PickSaveFileAsync();


                if (itemToSave != null)
                {
                    await Windows.Storage.FileIO.WriteTextAsync(itemToSave, personData);

                    _personCompare = CurrentPerson.ToJson();
                    result         = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(result);
        }
Exemplo n.º 20
0
        public PersonSearch(Session Session, string Forname, string Surname, int HierarchyId, Course Course, PersonType PersonType)
        {
            HttpWebRequest InitialLoginRequest = Session.GetHttpWebRequest("/search/search_person.aspx");
            HtmlDocument initialLoginScreen = new HtmlDocument();
            HttpWebResponse FirstResponse = (HttpWebResponse)InitialLoginRequest.GetResponse();
            initialLoginScreen.Load(FirstResponse.GetResponseStream());

            Dictionary<string, string> LoginFormData = new Dictionary<string, string>();

            LoginFormData.Add("FirstName", Forname);
            LoginFormData.Add("Lastname", Surname);
            LoginFormData.Add("CourseID", Course.Id.ToString());
            LoginFormData.Add("HierarchyId", HierarchyId.ToString());

            LoginFormData.Add("idProfileID_7", (((PersonType & PersonType.sysadmin) > 0) ? 7 : 0).ToString());
            LoginFormData.Add("idProfileID_14", (((PersonType & PersonType.examinator) > 0) ? 14 : 0).ToString());
            LoginFormData.Add("idProfileID_8", (((PersonType & PersonType.administrator) > 0) ? 8 : 0).ToString());
            LoginFormData.Add("idProfileID_9", (((PersonType & PersonType.employee) > 0) ? 9 : 0).ToString());
            LoginFormData.Add("idProfileID_10", (((PersonType & PersonType.student) > 0) ? 10 : 0).ToString());
            LoginFormData.Add("idProfileID_62007", (((PersonType & PersonType.parent) > 0) ? 62007 : 0).ToString());
            LoginFormData.Add("idProfileID_11", (((PersonType & PersonType.guest) > 0) ? 11 : 0).ToString());

            LoginFormData.Add("Search", "Søk");
            LoginFormData.Add("Advanced", "0");

            foreach (var Form in initialLoginScreen.DocumentNode.Descendants("form"))
            {
                if (Form.GetAttributeValue("name", "") == "form")
                {
                    foreach (var inp in initialLoginScreen.DocumentNode.Descendants("input"))
                    {
                        if (!LoginFormData.ContainsKey(inp.GetAttributeValue("name", ""))) LoginFormData.Add(inp.GetAttributeValue("name", ""), inp.GetAttributeValue("value", ""));
                    }
                    HtmlDocument doc = Session.PostData("/search/search_person.aspx", LoginFormData);
                    _Result = new List<Person>(10);
                    foreach (var row in (from element in doc.DocumentNode.DescendantNodes() where element.GetAttributeValue("id", "").StartsWith("row_") select element))
                    {
                        string href = row.ChildNodes[1].FirstChild.GetAttributeValue("href", "");
                        _Result.Add(new Person(Session, uint.Parse(HttpUtility.ParseQueryString(new Uri(Properties.Settings.Default.urlBase + href.Substring(href.IndexOf('/'))).Query).Get("PersonID"))));
                    }
                }
            }
        }
Exemplo n.º 21
0
    public Person AddPerson(PersonType type)
    {
        switch (type)
        {
        case PersonType.Warrior: return(new Warrior(this));

        case PersonType.Knight: return(new Knight(this));

        case PersonType.Jaeger: return(new Jaeger(this));

        case PersonType.Archer: return(new Archer(this));

        case PersonType.Necromancer: return(new Necromancer(this));

        case PersonType.DeathKnight: return(new DeathKnight(this));

        default: return(null);
        }
    }
        private bool HasAccess(string token, PersonType personType, ActionExecutingContext context)
        {
            if (string.IsNullOrEmpty(token))
            {
                switch (CurrentControllerName.ToLower() + "/" + CurrentActionName.ToLower())
                {
                case "home/index":
                case "account/login":
                case "account/signup":
                case "book/search":
                case "help/index":
                case "help/contact":
                case "book/index":
                    return(true);

                default: return(false);
                }
            }
            else
            {
                // according to the type of this user give him access
                switch (CurrentControllerName.ToLower() + "/" + CurrentActionName.ToLower())
                {
                case "home/index":
                case "account/login":
                case "account/signup":
                case "book/search":
                case "help/index":
                case "help/contact":
                case "book/index":
                    return(true);

                case "librarian/index":
                case "librarian/checkout":
                    return(personType >= PersonType.Librarian);

                case "admin/manage":
                    return(personType >= PersonType.Admin);

                default: return(true);
                }
            }
        }
Exemplo n.º 23
0
        public static PersonType CreateNewPerson()
        {
            PersonType result = new PersonType();

            result.Name = new PersonNameType()
            {
                FormattedName = "Name Not Provided"
            };
            result.Id = new IdentifierType()
            {
                Value = "Not Provided"
            };
            result.LegalId = new IdentifierType()
            {
                Value = "Not Provided"
            };
            result.Licenses         = new ObservableCollection <LicenseType>();
            result.IdentifyingMarks = new ObservableCollection <string>();
            result.Nationality      = new ObservableCollection <string>();
            result.PassportId       = new IdentifierType()
            {
                Value = "Not Provided"
            };
            result.Patents             = new ObservableCollection <PatentType>();
            result.Publications        = new ObservableCollection <PublicationType>();
            result.Qualifications      = new ObservableCollection <PersonCompetencyType>();
            result.Race                = new ObservableCollection <string>();
            result.References          = new ObservableCollection <RefereeType>();
            result.ResidenceCountry    = new ObservableCollection <CountryCodeList>();
            result.SecurityCredentials = new ObservableCollection <SecurityCredentialType>();
            result.Visa                = new ObservableCollection <string>();
            result.Affiliations        = new ObservableCollection <OrganizationAffiliationType>();
            result.Attachments         = new ObservableCollection <AttachmentType>();
            result.Certifications      = new ObservableCollection <CertificationType>();
            result.Citizenship         = new ObservableCollection <CountryCodeList>();
            result.Education           = new ObservableCollection <EducationAttendanceType>();
            result.Employment          = new ObservableCollection <EmployerHistoryType>();
            result.Ethnicity           = new ObservableCollection <string>();

            _personCompare = result.ToJson();
            return(result);
        }
        private IDictionary <string, PeopleIKnowMetadata> GetSystemFavorites(IMailboxSession session)
        {
            Dictionary <string, PeopleIKnowMetadata> dictionary = new Dictionary <string, PeopleIKnowMetadata>();

            using (IFolder folder = this.xsoFactory.BindToFolder(session, DefaultFolderType.RecipientCache))
            {
                using (IQueryResult queryResult = folder.PersonItemQuery(PeopleIKnowEmailAddressCollectionFolderProperty.EmptyFilter, PeopleIKnowEmailAddressCollectionFolderProperty.EmptyFilter, PeopleIKnowEmailAddressCollectionFolderProperty.AnySort, PeopleIKnowEmailAddressCollectionFolderProperty.RecipientCacheProperties))
                {
                    IStorePropertyBag[] propertyBags;
                    do
                    {
                        propertyBags = queryResult.GetPropertyBags(10000);
                        if (propertyBags != null && propertyBags.Length > 0)
                        {
                            foreach (IStorePropertyBag storePropertyBag in propertyBags)
                            {
                                PersonType valueOrDefault = storePropertyBag.GetValueOrDefault <PersonType>(PersonSchema.PersonType, PersonType.Unknown);
                                if (valueOrDefault == PersonType.Person)
                                {
                                    Participant[] valueOrDefault2 = storePropertyBag.GetValueOrDefault <Participant[]>(PersonSchema.EmailAddresses, null);
                                    int           valueOrDefault3 = storePropertyBag.GetValueOrDefault <int>(PersonSchema.RelevanceScore, int.MaxValue);
                                    if (valueOrDefault2 != null && valueOrDefault2.Length > 0)
                                    {
                                        foreach (Participant participant in valueOrDefault2)
                                        {
                                            if (!string.IsNullOrEmpty(participant.EmailAddress) && !this.DoesEmailAddressMatchMailboxOwner(participant.EmailAddress, session.MailboxOwner))
                                            {
                                                dictionary[participant.EmailAddress] = new PeopleIKnowMetadata
                                                {
                                                    RelevanceScore = valueOrDefault3
                                                };
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }while (propertyBags.Length > 0);
                }
            }
            return(dictionary);
        }
Exemplo n.º 25
0
        private static Type GetType(PersonType type)
        {
            switch (type)
            {
            case PersonType.Angle:
                return(typeof(Angle));

            case PersonType.Asian:
                return(typeof(Asian));

            case PersonType.Jute:
                return(typeof(Jute));

            case PersonType.Saxon:
                return(typeof(Saxon));

            default:
                return(null);
            }
        }
Exemplo n.º 26
0
        public string DeletePerson(Guid personId, PersonType personType)
        {
            var checkExists = _personRepository.GetPerson(personId);

            if (checkExists == null)
            {
                return(personType == PersonType.Actor ? ErrorMessages.ACTOR_NOT_FOUND : ErrorMessages.PRODUCER_NOT_FOUND);
            }
            else
            {
                if (_personRepository.DeletePerson(personId))
                {
                    return(string.Empty);
                }
                else
                {
                    return(personType == PersonType.Actor ? ErrorMessages.ACTOR_MAPPED : ErrorMessages.PRODUCER_MAPPED);
                }
            }
        }
        /// <summary>
        /// Uploads photo asynchronous.
        /// </summary>
        /// <param name="personType">The person type.</param>
        /// <param name="photo">The byte array of photo.</param>
        /// <param name="personId">Person Id.</param>
        /// <param name="personEvent">The person event.</param>
        /// <returns>
        /// Upload media Items.
        /// </returns>
        public async Task<string> UploadPhotosAsync(PersonType personType, byte[] photo, string personId, PersonEvent personEvent)
        {
            string fileName = string.Format("{0}{1}", personId, CommonConstants.ImageFormat);

            var mediaAddress = await this.GetBaseAddress(personType);
            var uploadedUrl = await this.imageMediaClient.UploadAsync(mediaAddress, photo, fileName);

            string personTypeValue = personType.RetrievePersonTypeFilterValue();

            if (uploadedUrl != null)
            {
                await this.personsClient.UpdateImageAsync(personId, personTypeValue, uploadedUrl, JsonConvert.SerializeObject(personEvent), true);
            }
            else
            {
                return await Task.FromResult(CommonConstants.Failed);
            }

            return await Task.FromResult(CommonConstants.Success);
        }
Exemplo n.º 28
0
        public ActionResult Create(PersonTypeViewModel personTypeViewModel)
        {
            try
            {
                PersonType personType = new PersonType();
                personType.PersonTypeName = personTypeViewModel.PersonTypeName;
                using (var dbModel = new OneSmallStepContext())
                {
                    dbModel.PersonType.Add(personType);
                    dbModel.SaveChanges();
                }


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 29
0
        //the reason for this dispatch timer is twofold at the moment.
        //1. To ensure that the UI reflects the most up to date state of the
        //application. Not all changes can be event driven directly. So in
        //the timer tick, I set property values to triger the INotifyPropertyChanged
        //events.
        //2. To ensure that all activities in the MainPageViewModel are using the
        //latest version of the _PersonType object.  I have found that sometimes
        //during a string of events and metod calls, the _personType object does not
        //have he current version. But a second time around it does. So something is
        //blocking the reference update. The Timer Tick acts as a process interupt
        //allowing the reference update to happen within the UI thread. I do not like
        //the approach, but it works for now. Anyone reading this that has a suggestion
        //please speak up!
        private void Timer_Tick(object sender, object e)
        {
            _personType      = Utilities.Repository.CurrentPerson;
            StatusPersonName = _personType.Name.FormattedName;
            StatusMessage    = string.Empty;
            StatusColor      = null;

            //tests for
            Type t = MainContent.DataContext.GetType();
            Type u = typeof(ViewModels.ViewModelBase);

            if (!u.IsAssignableFrom(t))
            {
                (MainContent.DataContext as MCSI.UWP.HROpen.Controls.ViewModels.ViewModelBase).Pulse();
            }
            else
            {
                (MainContent.DataContext as ViewModelBase).Pulse();
            }
        }
        public List <Person> GetPeople(PersonType person)
        {
            List <Person> peoplesList = new List <Person>();

            string sqlExpression = string.Empty;

            switch (person)
            {
            case PersonType.Employee:
                sqlExpression = @"SELECT Id, Name + ' ' + Surname + ' ' + Patronymic FROM Employees";
                break;

            case PersonType.Student:
                sqlExpression = @"SELECT Id, Name + ' ' + Surname + ' ' + Patronymic FROM Students";
                break;
            }

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(sqlExpression, connection);

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    object[] objArr = new object[2];
                    reader.GetValues(objArr);

                    peoplesList.Add(new Person()
                    {
                        Id   = Convert.ToInt32(objArr[0]),
                        Name = (string)objArr[1],
                    });
                }

                reader.Close();
            }

            return(peoplesList);
        }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            List <TaxPayer> taxPayerList = new List <TaxPayer>();

            Console.Write("Número de contribuintes: ");
            int taxPayerNumber = int.Parse(Console.ReadLine());

            Console.WriteLine();

            for (int i = 1; i <= taxPayerNumber; i++)
            {
                Console.WriteLine("Dados do contribuinte {0}", i);
                Console.Write("Pessoa ou Organização: ");
                PersonType taxPayerType = Enum.Parse <PersonType>(Console.ReadLine());
                Console.Write("Nome ou Razão Social: ");
                string taxPayerName = Console.ReadLine();
                Console.Write("Receita anual: ");
                double taxPayerIncome = double.Parse(Console.ReadLine());
                if (taxPayerType == PersonType.P)
                {
                    Console.Write("Valor de despesas com saúde: ");
                    double healthExpenditure = double.Parse(Console.ReadLine());
                    taxPayerList.Add(new Person(taxPayerName, taxPayerIncome, taxPayerType, healthExpenditure));
                }
                else if (taxPayerType == PersonType.O)
                {
                    Console.Write("Número de funcinários: ");
                    int employeeNumber = int.Parse(Console.ReadLine());
                    taxPayerList.Add(new Organization(taxPayerName, taxPayerIncome, taxPayerType, employeeNumber));
                }
                else
                {
                    Console.WriteLine("Digite um valor válido (P / O)");
                }
            }
            Console.WriteLine("Pagamento de impostos: ");
            foreach (TaxPayer element in taxPayerList)
            {
                Console.WriteLine("Nome do contribuinte: {0}; Valor pago: $ {1:F2} ", element.Name, element.Tax());
            }
        }
Exemplo n.º 32
0
        public JsonResult CreatePersonTypeModel(int ptid)
        {
            JsonResult json = null;

            try
            {
                TempData["PersonType"] = new PersonType()
                {
                    Id = ptid
                };
                json = Json(new { created = true, message = "Person Type Model was successfully " }, "text/html", JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex);
                SetMessage(ex.Message, ApplicationMessage.Category.Error);
                json = Json(new { created = false, message = "Person Type Model creation failed!" }, "text/html", JsonRequestBehavior.AllowGet);
            }

            return(json);
        }
Exemplo n.º 33
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (AdditionalContactInfo == null ? 0 : AdditionalContactInfo.GetHashCode());
         hash = hash * 23 + (BusinessEntityId == default(int) ? 0 : BusinessEntityId.GetHashCode());
         hash = hash * 23 + (Demographics == null ? 0 : Demographics.GetHashCode());
         hash = hash * 23 + (EmailPromotion == default(int) ? 0 : EmailPromotion.GetHashCode());
         hash = hash * 23 + (FirstName == null ? 0 : FirstName.GetHashCode());
         hash = hash * 23 + (LastName == null ? 0 : LastName.GetHashCode());
         hash = hash * 23 + (MiddleName == null ? 0 : MiddleName.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (NameStyle == default(bool) ? 0 : NameStyle.GetHashCode());
         hash = hash * 23 + (PersonType == null ? 0 : PersonType.GetHashCode());
         hash = hash * 23 + (Rowguid == default(Guid) ? 0 : Rowguid.GetHashCode());
         hash = hash * 23 + (Suffix == null ? 0 : Suffix.GetHashCode());
         hash = hash * 23 + (Title == null ? 0 : Title.GetHashCode());
         return(hash);
     }
 }
Exemplo n.º 34
0
    public static GameObject GetArmyPrefab(PersonType type)
    {
        GameObject prefab = null;

        switch (type)
        {
        case PersonType.Warrior:
        case PersonType.Knight: prefab = ArmyPrefab[0]; break;

        case PersonType.Jaeger:
        case PersonType.Archer: prefab = ArmyPrefab[2]; break;

        case PersonType.Wizard:
        case PersonType.Engineer: prefab = ArmyPrefab[3]; break;

        case PersonType.Necromancer: prefab = ArmyPrefab[1]; break;

        case PersonType.DeathKnight: prefab = ArmyPrefab[4]; break;
        }
        return(prefab);
    }
Exemplo n.º 35
0
        private IList <MemberChapterIndexViewModel> FillChapters(string memberId, PersonType personType, List <Chapter> chapters)
        {
            var memberChapters = new List <MemberChapterIndexViewModel>();
            var mcs            = _context.MemberChapters.Where(m => m.ApplicationUserId == memberId && m.WhenExpires >= DateTime.Now).ToList();

            foreach (var mc in mcs)
            {
                var chapter = chapters.FirstOrDefault(c => c.Id == mc.ChapterId);
                memberChapters.Add(
                    new MemberChapterIndexViewModel
                {
                    ChapterId        = chapter.Id,
                    Name             = chapter.Name,
                    WhenExpires      = mc.WhenExpires.Value,
                    IsPrimary        = mc.IsPrimary,
                    IsExpiring       = _domainService.Expiration.IsExpiring(personType, mc.WhenExpires.Value),
                    DaysToExpiration = _domainService.Expiration.DaysToExpiration(mc.WhenExpires.Value)
                });
            }
            return(memberChapters);
        }
    protected void DeleteGroup_Click(object sender, EventArgs e)
    {
        string groupId = popDeleteGroup.ReferrerId;

        try
        {
            PersonType             personType = PersonManager.GetPersonTypeById(groupId);
            IList <PersonTypeRole> roles      = PersonManager.GetPersonTypeRoleByPerson(personType);
            if (roles.Count > 0)
            {
                ((IFeedback)Master).SetError(GetType(), ErrorDeletePersonTypeWithRoles);
            }
            else
            {
                // Are there any people assigned to this person type?
                IList <Person> peopleInGroup = PersonManager.GetAllPersonsByPersonType(personType);

                if (peopleInGroup.Count > 0)
                {
                    ((IFeedback)Master).SetError(GetType(), ErrorDeletePersonTypeWithPersons);
                }
                else
                {
                    PersonManager.DeletePersonType(personType.Id);

                    ((IFeedback)Master).ShowFeedback(
                        BusiBlocksConstants.Blocks.Administration.LongName,
                        personType.GetType().Name,
                        Feedback.Actions.Deleted,
                        personType.Name
                        );
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Master).SetException(GetType(), ex);
        }
    }
Exemplo n.º 37
0
        /// <summary>
        /// Возвращает информацию о представителе
        /// </summary>
        /// <param name="person">
        /// The person.
        /// </param>
        /// <param name="statement">
        /// The statement.
        /// </param>
        protected virtual void FillRepresentative(PersonType person, Statement statement)
        {
            if (person.PR == null)
            {
                statement.Representative = null;
                return;
            }

            var conceptManager = ObjectFactory.GetInstance <IConceptCacheManager>();
            var representative = statement.Representative ?? new Representative();

            representative.LastName   = person.PR.FAM;
            representative.FirstName  = person.PR.IM;
            representative.MiddleName = person.PR.OT;
            representative.HomePhone  = person.PR.PHONE;
            representative.WorkPhone  = person.PR.PHONE_WORK;

            if (!string.IsNullOrEmpty(person.PR.RELATION))
            {
                representative.RelationType =
                    conceptManager.GetBy(x => x.Code == person.PR.RELATION && x.Oid.Id == Oid.Отношениекзастрахованномулицу)
                    .FirstOrDefault();
            }

            if (person.PR.DOC != null)
            {
                var category     = DocumentCategory.Unknown;
                var document     = representative.Document ?? new Document();
                var tempDocument = GetDocument(person.PR.DOC, ref category);
                document.DocumentType     = tempDocument.DocumentType;
                document.Series           = tempDocument.Series;
                document.Number           = tempDocument.Number;
                document.IssuingAuthority = tempDocument.IssuingAuthority;
                document.DateIssue        = tempDocument.DateIssue;
                document.DateExp          = tempDocument.DateExp;
                representative.Document   = document;
            }

            statement.Representative = representative;
        }
Exemplo n.º 38
0
        public ApplicantDataService()
        {
            Person person1 = new Person();
            person1.FirstName = "Alain";
            person1.LastName = "Tellenbach";
            person1.Email = "*****@*****.**";

            PersonType person1Type = new PersonType();
            person1Type.Type = "Chef";
            person1Type.AdditionalInfos = "Zuständig fürs Universums";
            person1.PersonType = person1Type;

            person1.DateOfBirth = new DateTime(1997, 3, 17);

            Job person1Job = new Job();
            person1Job.Name = "Informatiker Applikationsentwickler";
            person1Job.Applicant = true;
            person1.Job = person1Job;

            Person person2 = new Person();
            person2.FirstName = "Nichtalain";
            person2.LastName = "Nichttellenbach";
            person2.Email = "*****@*****.**";

            PersonType person2Type = new PersonType();
            person2Type.Type = "Nicht Chef";
            person2Type.AdditionalInfos = "Nicht zuständig fürs Universums";
            person2.PersonType = person2Type;

            person2.DateOfBirth = new DateTime(1997, 3, 17);

            Job person2Job = new Job();
            person2Job.Name = "Informatiker Nichtapplikationsentwickler";
            person2Job.Applicant = true;
            person2.Job = person2Job;

            persons.Add(person1);
            persons.Add(person2);
        }
Exemplo n.º 39
0
        public PersonType GetPersonType(int id)
        {
            PersonType personType = PersonType.NN;

            using (SqlCommand sqlCommand = new SqlCommand("SELECT Name from PersonType where PersonTypeId = @id", cnn))
            {
                sqlCommand.Parameters.AddWithValue("@id", id);
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    if (reader.HasRows && reader.Read())
                    {
                        string name = reader["Name"].ToString().Trim();
                        if (!string.IsNullOrEmpty(name))
                        {
                            personType = Enum.GetValues(typeof(PersonType)).Cast <PersonType>().Where(x => x.ToString().CompareTo(name) == 0).FirstOrDefault();
                        }
                    }
                    reader.Close();
                }
            }
            return(personType);
        }
Exemplo n.º 40
0
        /// <summary>
        /// Заполняет коды надежности идентификации
        /// </summary>
        /// <param name="person">
        /// The person.
        /// </param>
        /// <param name="statement">
        /// The statement.
        /// </param>
        protected virtual void FillDost(PersonType person, Statement statement)
        {
            if (person != null && person.DOST == null)
            {
                statement.InsuredPersonData.BirthdayType    = (int)BirthdayType.Full;
                statement.InsuredPersonData.IsIncorrectDate = false;
                return;
            }

            statement.InsuredPersonData.BirthdayType = (int)BirthdayType.Full;
            if (person != null && person.DOST.Contains("4"))
            {
                statement.InsuredPersonData.BirthdayType = (int)BirthdayType.MonthAndYear;
            }

            if (person != null && person.DOST.Contains("5"))
            {
                statement.InsuredPersonData.BirthdayType = (int)BirthdayType.Year;
            }

            statement.InsuredPersonData.IsIncorrectDate = person != null && person.DOST.Contains("6");
        }
Exemplo n.º 41
0
        /// <summary>
        /// This method adds some data to the DataBase, for Testing purposes.
        /// </summary>
        public void InitializeData()
        {
            SGCISTestContext context = new SGCISTestContext();

            var personType1 = new PersonType
            {
                Description = "Teacher"
            };

            var personType2 = new PersonType
            {
                Description = "Student"
            };

            context.PersonTypes.Add(personType1);
            context.PersonTypes.Add(personType2);

            var person1 = new Person
            {
                Age          = 15,
                Name         = "Andrew Thomas",
                PersonType   = personType2,
                PersonTypeId = personType2.Id
            };

            var person2 = new Person
            {
                Age          = 45,
                Name         = "John Smith",
                PersonType   = personType1,
                PersonTypeId = personType1.Id
            };

            context.Persons.Add(person1);
            context.Persons.Add(person2);

            context.SaveChanges();
        }
Exemplo n.º 42
0
    public static PersonCarlos Create(PersonType personType)
    {
        PersonCarlos p = null;

        switch (personType)
        {
        case PersonType.Soldier:
            p = (PersonCarlos)Resources.Load("Soldier", typeof(PersonCarlos));
            break;

        case PersonType.Civilian:
            p = (PersonCarlos)Resources.Load("Civilian", typeof(PersonCarlos));
            break;

        default:
            p = (PersonCarlos)Resources.Load("Civilian", typeof(PersonCarlos));
            break;
        }

        p = (PersonCarlos)Instantiate(p);

        return(p);
    }
Exemplo n.º 43
0
 private Person CreatePerson(string name, int age, PersonType personType)
 {
     if (personType == PersonType.Angles)
     {
         return(new Angles(name, age));
     }
     else if (personType == PersonType.Saxons)
     {
         return(new Saxons(name, age));
     }
     else if (personType == PersonType.Saxons)
     {
         return(new Saxons(name, age));
     }
     else if (personType == PersonType.Saxons)
     {
         return(new Saxons(name, age));
     }
     else
     {
         return(new Person(name, age));
     }
 }
Exemplo n.º 44
0
        public virtual async Task <UpdateResponse <ApiPersonTypeServerResponseModel> > Update(
            int id,
            ApiPersonTypeServerRequestModel model)
        {
            var validationResult = await this.PersonTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PersonType record = this.DalPersonTypeMapper.MapModelToEntity(id, model);
                await this.PersonTypeRepository.Update(record);

                record = await this.PersonTypeRepository.Get(id);

                ApiPersonTypeServerResponseModel apiModel = this.DalPersonTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PersonTypeUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPersonTypeServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPersonTypeServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemplo n.º 45
0
 public Person(
     string first,
     string last,
     DateTime birthDate,
     DateTime?nullableBirthDate,
     int age,
     int?nullableAge,
     string notes,
     PersonType personType,
     PersonType?nullablePersonType,
     bool isHandsome)
 {
     FirstName         = first;
     LastName          = last;
     Birthdate         = birthDate;
     NullableBirthdate = nullableBirthDate;
     Age          = age;
     NullableAge  = nullableAge;
     Notes        = notes;
     Type         = personType;
     NullableType = nullablePersonType;
     IsHandsome   = isHandsome;
 }
        public void Setup()
        {
            DbContextOptions options = new DbContextOptionsBuilder <ControlPanelEntities>()
                                       .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                       .Options;

            _db = new ControlPanelEntities(options);

            var mock = new Mock <IUnitOfWork>();

            mock.Setup(o => o.PersonsRepository).Returns(new PersonsRepository(_db));
            mock.Setup(o => o.Save()).Callback(() => _db.SaveChanges());
            _uow = mock.Object;

            //Setup common db entries
            PersonType personType = new PersonType()
            {
                Name = "Individual"
            };

            _db.PersonTypes.Add(personType);
            _db.SaveChanges();
        }
        /// <summary>
        /// Retrieve Base address for upload photo
        /// </summary>
        /// <param name="personType">person type</param>
        /// <returns>return base address</returns>
        private async Task<string> GetBaseAddress(PersonType personType)
        {
            string mediaAddress = string.Empty;
            UploadAddresses uploadAddresses = await this.RetrieveUploadPhotoBaseUrlAsync();

            if (uploadAddresses != null)
            {
                if (personType.Equals(PersonType.Crewmember))
                {
                    mediaAddress = uploadAddresses.CrewmembersSecurityPhotoUploadAddress;
                }
                else if (personType.Equals(PersonType.Visitor))
                {
                    mediaAddress = uploadAddresses.VisitorSecurityPhotoUploadAddress;
                }
                else if (personType.Equals(PersonType.Guest))
                {
                    mediaAddress = uploadAddresses.GuestSecurityPhotoUploadAddress;
                }
            }

            return mediaAddress;
        }
Exemplo n.º 48
0
    public Person(PersonType type, RootPerson root)
    {
        personType = type;

        switch (type)
        {
        case PersonType.partner:
            GenPartner(root);
            break;

        case PersonType.roommate:
            GenRoommate(root);
            break;

        case PersonType.child:
            Debug.LogError("Used non-child constructor to initialize child");
            break;

        default:
            Debug.LogError("Invalid person type");
            break;
        }
    }
Exemplo n.º 49
0
        /// <summary>
        /// gets a person object
        /// </summary>
        /// <param name="id">the primary key of the person</param>
        /// <param name="pType">the type of the person</param>
        /// <returns>a Person</returns>
        public static Person getPerson(int id, PersonType pType)
        {
            Person person = null;

            try
            {
                SqlConnection conn = new SqlConnection(ConnectionManager.GetUnauthentifiedConnectionString());
                SqlTransaction transaction;

                conn.Open();

                transaction = conn.BeginTransaction(IsolationLevel.ReadUncommitted);
                try
                {
                    SqlCommand cmd = new SqlCommand("SELECT P.id_person as id_person, P.email, P.firstname, P.lastname, P.username, P.pType AS pType, P.timestamp " +
                            "FROM [Person] P WHERE P.id_person = @id_person AND P.pType=@pType;", conn, transaction);

                    cmd.Parameters.Add("@id_person", SqlDbType.Int).Value = id;
                    cmd.Parameters.Add("@pType", SqlDbType.Char).Value = Person.dbTypesRev[pType];

                    SqlDataReader rdr = cmd.ExecuteReader();

                    if (rdr.Read())
                    {
                        string firstname = rdr.GetString(rdr.GetOrdinal("firstname"));
                        string lastname = rdr.GetString(rdr.GetOrdinal("lastname"));
                        string email = rdr.GetString(rdr.GetOrdinal("email"));
                        string username = rdr.GetString(rdr.GetOrdinal("username"));
                        int id_person = rdr.GetInt32(rdr.GetOrdinal("id_person"));
                        string dbType = rdr.GetString(rdr.GetOrdinal("pType"));

                        person = new Person(Person.dbTypes[dbType], id_person, firstname, lastname, username, email, "");

                        byte[] buffer = new byte[100];
                        rdr.GetBytes(rdr.GetOrdinal("timestamp"), 0, buffer, 0, 100);
                        person.setTimestamp(buffer);
                    }
                    rdr.Close();
                    transaction.Commit();
                }
                catch (SqlException sqlError)
                {
                    System.Diagnostics.Debug.WriteLine(sqlError.Message);
                    System.Diagnostics.Debug.WriteLine(sqlError.StackTrace);
                    transaction.Rollback();
                    throw new GrException(sqlError, Messages.errProd);
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                System.Diagnostics.Debug.WriteLine(ex.StackTrace);
                throw (ex is GrException) ? ex : new GrException(ex, Messages.errProd);
            }

            return person;
        }
        public void TestSerialiseLazyManyToOne()
        {
            Person p = BusinessObjectFactory.CreateAndFillPerson();
            Address addr = new Address
            {
                Address1 = "12 Street",
                Suburb = "Suburb",
                State = "QLD",
                Postcode = "1234"
            };
            p.Addresses.Add(addr);

            PersonType ptype = new PersonType
            {
                ID = "contact",
                Description = "General Contact"
            };
            ptype.Save(SaveMode.Flush);
            p.ContactType = ptype;
            p.Save(SaveMode.Flush);

            p.Evict();
            ptype.Evict();

            Person loadedPerson = Person.Load(p.ID, session);
            Person newPerson = loadedPerson.Clone();

            Assert.Equal(p.ID, newPerson.ID);
            Assert.Equal("contact", newPerson.ContactType.ID);
        }
        /// <summary>
        /// Retrieves the persons by person identifier.
        /// </summary>
        /// <param name="shipId">The ship identifier.</param>
        /// <param name="personType">Type of the person.</param>
        /// <param name="personId">The person identifier.</param>
        /// <param name="startDate">Start date time</param>
        /// <param name="endDate">End date time</param>
        /// <param name="shipDateTime">Current ship date time</param>
        /// <returns>List of Person</returns>
        private async Task<string> RetrievePersonsByPersonId(string shipId, PersonType personType, string startDate, string endDate, string personId, string shipDateTime)
        {
            var task = string.Empty;
            var workstation = DIContainer.Instance.Resolve<Workstation>();
            string itineraryDate = workstation.CurrentDateTime.ToString(CommonConstants.DateFormat, CultureInfo.CurrentCulture);

            if (personType == PersonType.Guest)
            {
                task = await this.personsClient.RetrievePersonsAsync(shipId, guestIds: personId, startDate: startDate, endDate: endDate, alertMessageStartDate: shipDateTime, alertMessageEndDate: shipDateTime, portId: workstation.Port.PortId, portArrivalDate: itineraryDate);
            }
            else if (personType == PersonType.Crewmember)
            {
                task = await this.personsClient.RetrievePersonsAsync(shipId, crewmemberIds: personId, startDate: startDate, endDate: endDate, alertMessageStartDate: shipDateTime, alertMessageEndDate: shipDateTime, portId: workstation.Port.PortId, portArrivalDate: itineraryDate);
            }
            else if (personType == PersonType.Visitor)
            {
                task = await this.personsClient.RetrievePersonsAsync(shipId, visitorIds: personId, startDate: startDate, endDate: endDate, alertMessageStartDate: shipDateTime, alertMessageEndDate: shipDateTime, portId: workstation.Port.PortId, portArrivalDate: itineraryDate);
            }

            return task;
        }
 /// <summary>
 /// Retrieves the person event asynchronous.
 /// </summary>
 /// <param name="dateTime">The date time.</param>
 /// <param name="personId">The person identifier.</param>
 /// <param name="personType">The person type.</param>
 /// <returns>The person events.</returns>
 public async Task<EventHistory> RetrievePersonHistoryAsync(string dateTime, string personId, PersonType personType)
 {
     var workstation = DIContainer.Instance.Resolve<Workstation>();
     string personTypeValue = personType.RetrievePersonTypeFilterValue();
     var task = await this.personsClient.RetrievePersonEventAsync(shipId: workstation.Ship.ShipId, dateTime: dateTime, personId: personId, personType: personTypeValue);
     ListResult<EventHistory> eventData = task != null ? JsonConvert.DeserializeObject<ListResult<EventHistory>>(task) : default(ListResult<EventHistory>);
     var data = eventData != null ? eventData.Items.FirstOrDefault() : new EventHistory();
     return await Task.FromResult(data);
 }
        /// <summary>
        /// Fills the details for popup.
        /// </summary>
        /// <param name="selectedItem">The selected item.</param>
        private void RetrievePersonDetail(GangwayHistory selectedItem)
        {
            var task = Task.Run(async () => await PersonsService.RetrievePersonsBySearchText(Workstation.Ship.ShipId, null, new List<PersonType>() { selectedItem.PersonType }, SearchType.PersonId, personId: selectedItem.PersonId, folioNumber: null));
            task.Wait();
            if (!task.IsCanceled && !task.IsFaulted)
            {
                this.personDetail = task.Result;
                this.personTypeForPopup = selectedItem.PersonType;
            }

            this.RetrieveCountries();
            this.RetrieveLoyaltyLevelTypes();
        }
        /// <summary>
        /// Assigns the person to person base.
        /// </summary>
        /// <param name="person">The person.</param>
        /// <param name="personType">Type of the person.</param>
        private void AssignPersonToPersonBase(Person person, PersonType personType)
        {
            this.personBase = null;
            if (personType == PersonType.Guest)
            {
                var guest = person.Guests.FirstOrDefault();
                if (guest != null)
                {
                    this.personBase = guest.MapToPersonBase();
                }
            }
            else if (personType == PersonType.Crewmember)
            {
                var crewmember = person.Crewmembers.FirstOrDefault();
                if (crewmember != null)
                {
                    this.personBase = crewmember.MapToPersonBase();
                }
            }
            else if (personType == PersonType.Visitor)
            {
                var visitor = person.Visitors.FirstOrDefault();
                if (visitor != null)
                {
                    this.personBase = visitor.MapToPersonBase();
                }
            }

            Messenger.Instance.Notify(MessengerMessage.ShowSpinWheel, false);

            if (this.personBase != null)
            {
                this.personBase.PersonalDetail.Country = this.allCountries.FirstOrDefault(a => a.CountryId.Equals(this.personBase.PersonalDetail.CitizenshipCountryId));
                this.personBase.LoyaltyLevel = CommonMethods.RetrieveLoyaltyLevelNameById(this.tempLoyaltyLevelTypes, this.personBase.CruiseDetail);

                Messenger.Instance.Notify(MessengerMessage.ShowPersonInfo, new Tuple<PersonBase, bool>(this.personBase, true));
            }
        }
Exemplo n.º 55
0
        /// <summary>
        /// Function to retrieve existing person from party for a card number.
        /// </summary>
        /// <param name="cardNumber">Number of card</param>l
        /// <param name="personType">Type of person</param>
        /// <param name="cardDetail">The card detail.</param>
        /// <returns>
        /// Instance of PersonBase
        /// </returns>
        public PersonBase RetrieveExistingPersonForCardNumber(string cardNumber, PersonType personType, CardInformation cardDetail)
        {
            if (this.CurrentParty != null && this.CurrentParty.IsPartyCreated)
            {
                if (personType == PersonType.Guest)
                {
                    return this.RetrieveGuestforCard(cardNumber, cardDetail);
                }

                if (personType == PersonType.Crewmember && this.CurrentParty.Crew.Count > 0)
                {
                    var crewMember = this.CurrentParty.Crew.FirstOrDefault(c => c.CrewmemberAccessCards.Any(f => !string.IsNullOrEmpty(f.AccessCardNumber) && f.AccessCardNumber.Equals(cardNumber, StringComparison.OrdinalIgnoreCase)));
                    return crewMember != null ? crewMember.MapToPersonBase() : null;
                }

                if (personType == PersonType.Visitor && this.CurrentParty.Visitors.Count > 0)
                {
                    var visitor = this.CurrentParty.Visitors.FirstOrDefault(c => !string.IsNullOrEmpty(c.CardNumber) && c.CardNumber.Equals(cardNumber, StringComparison.OrdinalIgnoreCase));
                    return visitor != null ? visitor.MapToPersonBase() : null;
                }
            }

            return null;
        }
Exemplo n.º 56
0
 /// <summary>
 /// Retrieves the person event asynchronous.
 /// </summary>
 /// <param name="dateTime">The date time.</param>
 /// <param name="personId">The person identifier.</param>
 /// <param name="personType">The person type.</param>
 /// <returns>
 /// The person events.
 /// </returns>
 public async Task<EventHistory> RetrievePersonHistoryAsync(string dateTime, string personId, PersonType personType)
 {
     return await this.personServiceRepository.RetrievePersonHistoryAsync(dateTime, personId, personType);
 }
Exemplo n.º 57
0
        /// <summary>
        /// Retrieves the person event asynchronous.
        /// </summary>
        /// <param name="dateTime">The date time.</param>
        /// <param name="personId">The person identifier.</param>
        /// <param name="personType">The person type.</param>
        /// <returns>The person events.</returns>
        public async Task<EventHistory> RetrievePersonHistoryAsync(string dateTime, string personId, PersonType personType)
        {
            var workstation = DIContainer.Instance.Resolve<Workstation>();

            ListResult<EventHistory> eventData = new ListResult<EventHistory>();
            var eventHistory = new EventHistory();

            var personTypeId = personType.RetrievePersonTypeId();

            var command = this.Database.GetStoredProcCommand(RetrieveGangwayHistoryByPersonIdStoredProcedure)
                .AddParameter(PersonTypeId, DbType.Int16, personTypeId)
                .AddParameter(PersonIds, DbType.String, personId)
                .AddParameter(ShipIds, DbType.String, workstation.Ship.ShipId)
                .AddParameter(SortColumn1, DbType.String, AddedDate)
                .AddParameter(SortTypeColumn1, DbType.String, DESC)
                .AddParameter(PageNumber, DbType.Int32, OfflineConstants.DefaultPageNumber)
                .AddParameter(PageSize, DbType.Int32, OfflineConstants.DefaultPageSize);

            var list = await this.ExecuteReaderAsync(command, GangwayHistoryMapper.MapGangwayHistory);

            eventHistory.AssignGangwayEvents(PersonEventHistoryMapper.MapPersonHistory(list.Items));
            eventData.Items.Add(eventHistory);
            var data = eventData != null ? eventData.Items.FirstOrDefault() : new EventHistory();
            return await Task.FromResult(data);
        }
 /// <summary>
 /// Function to retrieve search person.
 /// </summary>
 /// <param name="searchText">The search text.</param>
 /// <param name="searchType">Type of the search.</param>
 /// <param name="personType">Type of the person.</param>
 /// <param name="personId">The person identifier.</param>
 private void RetrieveSearchPerson(string searchText, SearchType searchType, PersonType personType, string personId)
 {
     var task = Task.Run(() => DIContainer.Instance.Resolve<SearchManager>().RetrievePersonsBySearchText(this.workstation.Ship.ShipId, searchText, new List<PersonType> { personType }, searchType, VisitorSearchType.None, personId, this.OnSearchCompleted, false, this.PageIndex, CommonConstants.MaxPageCount, folioNumber: null));
     task.Wait();
 }
Exemplo n.º 59
0
 /// <summary>
 /// whether or not this person has one of the given roles (types)
 /// </summary>
 /// <param name="roles">array of roles/types to test against</param>
 /// <returns>whether or not this person has a given role</returns>
 public Boolean IsInRole(PersonType[] roles)
 {
     foreach (PersonType r in roles)
     {
         if (r.Equals(pType))
             return true;
     }
     return false;
 }
Exemplo n.º 60
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">the type of this person</param>
 /// <param name="id_person">the primary key of this person</param>
 /// <param name="firstName">the first name of this person</param>
 /// <param name="lastName">the last name of this person</param>
 /// <param name="username">the username of this person</param>
 /// <param name="email">the email address of this person</param>
 /// <param name="password">the password of this person</param>
 public Person2(PersonType type, int id_person, string firstName, string lastName, string username, string email, string password)
 {
     pType = type;
     ID = id_person;
     FirstName = firstName;
     LastName = lastName;
     Email = email;
     Password = password;
     Username = username;
 }