public void GroupAdd()
        {
            Group group = new Group();

            string name1 = "maichao";
            string company1 = "ynu";
            string position1 = "student";

            Person person1 = new Person { Name = name1, Company = company1, Position = position1 };

            group.AddPerson(person1);

            Assert.AreEqual(1, group.Amount);

            string name2 = "mai";
            string company2 = "ynu";
            string position2 = "graduate";

            Person person2 = new Person { Name = name2, Company = company2, Position = position2 };

            group.AddPerson(person2);

            Assert.AreEqual(2, group.Amount);

            Assert.AreNotEqual(group.Persons[0], group.Persons[1]);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            p = (Person)Session["Person"];

            if (p != null)
            {
                itemTable.Visible = false;
                Label2.Visible = false;
                personTable.Visible = false;
                Label3.Visible = false;
                foreach (ShoppingList sl in p.shoppingLists)
                {
                    Button b = new Button();
                    TableRow row = new TableRow();
                    TableCell liste = new TableCell();
                    b.ID = sl.ShoppingListNumber.ToString();
                    b.Text = sl.Title;
                    b.Click += ItemButton_Click;
                    liste.Controls.Add(b);
                    row.Cells.Add(liste);
                    listTable.Rows.Add(row);
                }
            }
            else
            {
                Label1.Text = "Log venligst ind";
            }
        }
Beispiel #3
0
        // Methods

        public void AskForPersonInfo()              // Gets both person and their spouse info (if applicable)
        {

            personCount++;

            // Person info

            System.Console.Write("What is your first name?          : ");
            firstName = System.Console.ReadLine();

            System.Console.Write("What is your last name?           : ");
            lastName = System.Console.ReadLine();

            System.Console.Write("What is your age?                 : ");
            age = int.Parse(System.Console.ReadLine());
            
            // Spouse info
                    
            System.Console.Write("Are you married? (True/False)     : ");
            isMarried = bool.Parse(System.Console.ReadLine());

                    /*  USE FOR: string input above and convert to bool below. Above ReadLine would need to
                        take in a normal string for this to work:

                    if (System.Console.ReadLine().StartsWith("y")||System.Console.ReadLine().StartsWith("Y"))
                    {
                        isMarried = true;
                    }
                    */
            
            if (isMarried)
            {
                spouse = new Person();

                personCount++;

                spouse.isMarried = isMarried;

                System.Console.Write("Enter your spouse's first name    : ");
                spouse.firstName = System.Console.ReadLine();

                spouse.lastName = lastName;

                System.Console.Write("What is the age of your spouse?   : ");
                spouse.age = int.Parse(System.Console.ReadLine());

                this.spouse.spouse = this;      // relates 2nd person object (spouse) back to root of the class (first object) using ' = this '

                        // The spouse of my spouse... is the spouse, not p1/p2
                        // spouse.spouse = spouse;      -- not what I want

                sumOfAllAges += age + spouse.age;
            }
            else
            {
                sumOfAllAges += age;
            }
            

        }
		public void Serialize()
		{
			var serializer = new NewtonsoftJSONSerializer();

			var p = new Person { Name = "Json", Age = 23};
			Assert.AreEqual("{\"Name\":\"Json\",\"Age\":23}", serializer.Serialize(p));
		}
Beispiel #5
0
 public Project(object key, string number, string name)
     : base(key)
 {
     this.number = number;
     this.name = name;
     this.address = null;
     this.owner = null;
     this.constructionAdministrator = null;
     this.principal = null;
     this.contractDate = null;
     this.estimatedStartDate = null;
     this.estimatedCompletionDate = null;
     this.currentCompletionDate = null;
     this.actualCompletionDate = null;
     this.contingencyAllowanceAmount = 0;
     this.testingAllowanceAmount = 0;
     this.utilityAllowanceAmount = 0;
     this.originalConstructionCost = 0;
     this.totalChangeOrderDays = 0;
     this.adjustedConstructionCost = 0;
     this.totalChangeOrdersAmount = 0;
     this.totalSquareFeet = 0;
     this.percentComplete = 0;
     this.remarks = string.Empty;
     this.aeChangeOrderAmount = 0;
     this.contractReason = string.Empty;
     this.agencyApplicationNumber = string.Empty;
     this.agencyFileNumber = string.Empty;
     this.segment = null;
     this.allowances = new List<Allowance>();
 }
Beispiel #6
0
		public void Test()
		{
			int id = -1;
			
			using (ISession s = OpenSession())
			{
				var address1 = new Address("60", "EH3 8BE");
				var address2 = new Address("2", "EH6 6JA");
				s.Save(address1);
				s.Save(address2);
				
				var person1 = new Person("'lil old me");
				person1.AddPercentageToFeeMatrix(0, .20m);
				person1.AddPercentageToFeeMatrix(50, .15m);
				person1.AddPercentageToFeeMatrix(100, .1m);
				person1.RegisterChangeOfAddress(new DateTime(2005, 4, 15), address1);
				person1.RegisterChangeOfAddress(new DateTime(2007, 5, 29), address2);
				
				s.Save(person1);
				s.Flush();
				
				id = person1.Id;
			}
			
			using (ISession s = OpenSession())
			{
				var person1 = s.Load<Person>(id);
				person1.RegisterChangeOfAddress(new DateTime(2008, 3, 23), new Address("8", "SS7 1TT"));
				s.Save(person1);
				s.Flush();
			}
		}
Beispiel #7
0
        /// <summary>
        /// Checks if a person with a region can be added and then retrieved from it. 
        /// </summary>
        public void AddAndGetPersonWithRegion()
        {
            LightHouse.Core.Caching.DataCache dataCache = new LightHouse.Core.Caching.DataCache();

            String id = Guid.NewGuid().ToString();

            Person person = new Person()
            {
                ID = id,
                Reference = "1671",
                FirstName = new Localization.LocalString("Homer"),
                LastName = new Localization.LocalString("Simpson"),
            };

            String region = "Family";
            String falseRegion = "Acquaintances";

            dataCache.Add(person.ID, person, region);

            person.FirstName = new Localization.LocalString("Bart");

            Person cachedPerson = dataCache.Get<Person>(id, region);
            Person falsePerson = dataCache.Get<Person>(id, falseRegion);

            Assert.NotNull(cachedPerson);
            Assert.Null(falsePerson);
            Assert.Equal(cachedPerson.FirstName.GetContent(), "Bart");
        }
		public void EntityStoredProcedure()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			Organization ifa = new Organization("IFA");
			Organization jboss = new Organization("JBoss");
			Person gavin = new Person("Gavin");
			Employment emp = new Employment(gavin, jboss, "AU");
			s.Save(ifa);
			s.Save(jboss);
			s.Save(gavin);
			s.Save(emp);

			IQuery namedQuery = s.GetNamedQuery("selectAllEmployments");
			IList list = namedQuery.List();
			Assert.IsTrue(list[0] is Employment);
			s.Delete(emp);
			s.Delete(ifa);
			s.Delete(jboss);
			s.Delete(gavin);

			t.Commit();
			s.Close();
		}
        public void Example()
        {
            #region Usage
            Person person = new Person();

            string jsonIncludeDefaultValues = JsonConvert.SerializeObject(person, Formatting.Indented);

            Console.WriteLine(jsonIncludeDefaultValues);
            // {
            //   "Name": null,
            //   "Age": 0,
            //   "Partner": null,
            //   "Salary": null
            // }

            string jsonIgnoreDefaultValues = JsonConvert.SerializeObject(person, Formatting.Indented, new JsonSerializerSettings
            {
                DefaultValueHandling = DefaultValueHandling.Ignore
            });

            Console.WriteLine(jsonIgnoreDefaultValues);
            // {}
            #endregion

            Assert.AreEqual("{}", jsonIgnoreDefaultValues);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonViewModel"/> class.
        /// </summary>
        /// <param name="person">The person.</param>
        public PersonViewModel(Person person)
        {
            Person = person ?? new Person();

            GenerateData = new Command<object, object>(OnGenerateDataExecute, OnGenerateDataCanExecute);
            ToggleCustomError = new Command<object>(OnToggleCustomErrorExecute);
        }
Beispiel #11
0
 public static TestPerson BuildPersonFromDataBaseData(string idPerson, string MIS)
 {
     using (NpgsqlConnection connection = Global.GetSqlConnection())
     {
         string findPatient = "SELECT * FROM public.person WHERE id_person = '" + idPerson + "'";
         NpgsqlCommand person = new NpgsqlCommand(findPatient, connection);
         using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
         {
             Person p = new Person();
             while (personFromDataBase.Read())
             {
                 //что делать с DateSpecified и Мисами?
                 if (personFromDataBase["birthday"]!= DBNull.Value)
                     p.BirthDate = Convert.ToDateTime(personFromDataBase["birthday"]);
                 if (MIS == "")
                     p.IdPatientMis = null;
                 if ((personFromDataBase["family_name"] != DBNull.Value) || (personFromDataBase["given_name"] != DBNull.Value) || (personFromDataBase["middle_name"] != DBNull.Value))
                 {
                     p.HumanName = new HumanName();
                     if (personFromDataBase["family_name"] != DBNull.Value)
                         p.HumanName.FamilyName = Convert.ToString(personFromDataBase["family_name"]);
                     if (personFromDataBase["given_name"] != DBNull.Value)
                         p.HumanName.GivenName = Convert.ToString(personFromDataBase["given_name"]);
                     if (personFromDataBase["middle_name"] != DBNull.Value)
                         p.HumanName.MiddleName = Convert.ToString(personFromDataBase["middle_name"]);
                 }
                 TestPerson pers = new TestPerson(p);
                 if (personFromDataBase["id_sex"] != DBNull.Value)
                     pers.sex = TestCoding.BuildCodingFromDataBaseData(Convert.ToString(personFromDataBase["id_sex"]));
                 return pers;
             }
         }
     }
     return null;
 }
    protected string GetLine(int id, Person p, string colSep, string rowSep, bool incRowSep, bool incDOB, bool incAddresses, bool incPhoneNbrs, bool incRefInfo)
    {
        string result = string.Empty;
        if (incRowSep)
            result += rowSep;
        result += id.ToString() + colSep + p.Firstname + colSep + p.Middlename + colSep + p.Surname;
        if (incDOB)
            result += colSep + (p.Dob == DateTime.MinValue ? "" : p.Dob.ToString("dd-MM-yyyy"));
        if (incAddresses)
            result += colSep + GetAddresses(p.EntityID);
        if (incPhoneNbrs)
            result += colSep + GetPhoneNbrs(p.EntityID);

        if (incRefInfo)
        {
            string orgNames = string.Empty;
            string provNbrs = string.Empty;

            System.Data.DataTable tbl = RegisterReferrerDB.GetDataTable_OrganisationsOf(id);
            RegisterReferrer[] list = new RegisterReferrer[tbl.Rows.Count];
            for(int i=0; i<tbl.Rows.Count; i++)
            {
                list[i] = RegisterReferrerDB.Load(tbl.Rows[i]);
                list[i].Organisation = OrganisationDB.Load(tbl.Rows[i], "", "organisation_entity_id", "organisation_is_deleted");
                orgNames += (orgNames.Length == 0 ? "" : "\r\n") + list[i].Organisation.Name;
                provNbrs += (provNbrs.Length == 0 ? "" : "\r\n") + list[i].ProviderNumber;
            }

            result += colSep + orgNames;
            result += colSep + provNbrs;

        }

        return result;
    }
        public void TestCase2()
        {
            // test case 2 data setup
            // wallet 1 credit cards
            List<string> creditCardList1 = new List<string>();
            creditCardList1.Add("Visa");
            creditCardList1.Add("Discover");

            // wallet 2 credit cards
            List<string> creditCardList2 = new List<string>();
            creditCardList2.Add("MasterCard");

            Person personB = new Person();
            Wallet wallet1 = new Wallet(creditCardList1);
            personB.addWallet(wallet1);

            Assert.AreEqual(11, wallet1.getTotalInterest());

            Wallet wallet2 = new Wallet(creditCardList2);
            personB.addWallet(wallet2);

            Assert.AreEqual(5, wallet2.getTotalInterest());

            Assert.AreEqual(16, personB.getTotalInterestPerPerson());
        }
        public void TestCase3()
        {
            // test case 3 data setup
            // wallet 3 credit cards
            List<string> creditCardList3 = new List<string>();
            creditCardList3.Add("MasterCard");
            creditCardList3.Add("Visa");

            // wallet 4 credit cards
            List<string> creditCardList4 = new List<string>();
            creditCardList4.Add("Visa");
            creditCardList4.Add("MasterCard");

            Person personC = new Person();
            Wallet wallet3 = new Wallet(creditCardList3);
            personC.addWallet(wallet3);

            Assert.AreEqual(15, personC.getTotalInterestPerPerson());

            Person personD = new Person();
            Wallet wallet4 = new Wallet(creditCardList4);
            personD.addWallet(wallet4);

            Assert.AreEqual(15, personD.getTotalInterestPerPerson());
        }
Beispiel #15
0
    /// <summary>
    /// Обработчик аутентификации пользователя.
    /// </summary>
    protected virtual void OnLogin(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(logIn.UserName) || HttpContext.Current == null)
            return;

        Person currentUser = new Person(HttpContext.Current.User.Identity);
        if (!currentUser.LoadByDomainName(logIn.UserName))
            return;

        if (!currentUser.IsInRole(RolesEnum.PublicUser))
        {
            logIn.FailureText = "User cant work with the public portal.";
            return;
        }

        IList<PersonAttribute> attributes =
            PersonAttributes.GetPersonAttributesByKeyword(currentUser.ID.Value
                                                          , PersonAttributeTypes.PublicPassword.ToString());

        if (logIn.Password == (string)attributes[0].Value)
        {
            Session["UserID"] = currentUser.ID.Value;
            FormsAuthentication.RedirectFromLoginPage(logIn.UserName, logIn.RememberMeSet);
        }
        logIn.FailureText = "Incorrect information.";
    }
 public void Create(Person person)
 {
   t_person entity = new t_person();
   entity.UpdateEntity(person);
   _sqlRepository.Insert(entity);
   person.PersonId = entity.PersonId;
 }
        public async void TestOneToOneRecursiveInsertAsync() {
            var conn = Utils.CreateAsyncConnection();
            await conn.DropTableAsync<Passport>();
            await conn.DropTableAsync<Person>();
            await conn.CreateTableAsync<Passport>();
            await conn.CreateTableAsync<Person>();

            var person = new Person
            {
                Name = "John",
                Surname = "Smith",
                Passport = new Passport {
                    PassportNumber = "JS123456"
                }
            };

            // Insert the elements in the database recursively
            await conn.InsertWithChildrenAsync(person, recursive: true);

            var obtainedPerson = await conn.FindAsync<Person>(person.Identifier);
            var obtainedPassport = await conn.FindAsync<Passport>(person.Passport.Id);

            Assert.NotNull(obtainedPerson);
            Assert.NotNull(obtainedPassport);
            Assert.That(obtainedPerson.Name, Is.EqualTo(person.Name));
            Assert.That(obtainedPerson.Surname, Is.EqualTo(person.Surname));
            Assert.That(obtainedPassport.PassportNumber, Is.EqualTo(person.Passport.PassportNumber));
            Assert.That(obtainedPassport.OwnerId, Is.EqualTo(person.Identifier));
        }
Beispiel #18
0
        static void Main(string[] args)
        {
            /*
             * Rules
             *
             * External entities are only mapped one way (either to or from)
             * Data entities are mapped both ways
             **/

            AutoMapper.Mapper.AddProfile<MapperProfile>();

            // External Entites
            var addressExternalEntity = new AddressExternalEntity { Id = 1, Line1 = "Line1", Line2 = "Line2", Line3 = "Line3" };
            AutoMapper.Mapper.Map<AddressExternalEntity, Address>(addressExternalEntity);

            var personExternalEntity = new PersonExternalEntity {Id = 10, Name = "Bob"};
            AutoMapper.Mapper.Map<PersonExternalEntity, Person>(personExternalEntity);

            var personStatusResponse = new PersonStatusResponse {PersonId = 324};
            AutoMapper.Mapper.Map<PersonStatusResponse, PersonStatusResponseExternalEntity>(personStatusResponse);

            // Data Entities
            var address = new Address { Id = 1, Line1 = "Line1", Line2 = "Line2", Line3 = "Line3" };
            var addressDataEntity = AutoMapper.Mapper.Map<Address, AddressDataEntity>(address);
            address = AutoMapper.Mapper.Map<AddressDataEntity, Address>(addressDataEntity);

            var person = new Person { Id = 10, Name = "Bob" };
            var personDataEntity = AutoMapper.Mapper.Map<Person, PersonDataEntity>(person);
            person = AutoMapper.Mapper.Map<PersonDataEntity, Person>(personDataEntity);

            Console.ReadKey();
        }
 public MemberListViewItem(Person person)
 {
     IsChecked = false;
     Person = person;
     NumberOfPerson++;
     Id = NumberOfPerson;
 }
        public IQueryable<Commitment> RetrieveCommitmentsForDisaster(Person person, Disaster disaster)
        {
            if (disaster == null)
                throw new ArgumentNullException("disaster", "Disaster cannot be null");

            return RetrieveCommitments(person, true).Where(c => c.DisasterId == disaster.Id);
        }
Beispiel #21
0
        public void TestUpdate()
        {
            var person = new Person { Name = "Bob", Age = 50 };

            Connection
                .Insert(person)
                .Column(c => c.Name)
                .Column(c => c.Age)
                .ExecuteNonQuery();

            var saved = Connection
                .Select<Person>()
                .Column(c => c.Name)
                .Column(c => c.Age)
                .Query()
                .FirstOrDefault();

            saved.Name = "John";

            Connection
                .Update(saved)
                .Column(c => c.Name)
                .Where(p => p.Name == "Bob")
                .ExecuteNonQuery();

            var updated = Connection
                .Select<Person>()
                .Column(c => c.Name)
                .Column(c => c.Age)
                .Query()
                .FirstOrDefault();

            Assert.AreEqual("John", updated.Name);
        }
Beispiel #22
0
		public void ShouldWork()
		{
			using (var session = store.OpenSession())
			{
				var person = new Person
				{
					Id = "people/1",
					Name = "Person 1",
					Roles = new List<string>(),
					Permissions = new List<OperationPermission>()
				};
				session.Store(person);
				person.Permissions.Add(new OperationPermission()
				{
					Operation = "resources",
					Allow = true,
					Tags = {person.Id}
				});
				person = new Person
				{
					Id = "people/2",
					Name = "Person 2",
					Roles = new List<string>(),
					Permissions = new List<OperationPermission>()
				};
				session.Store(person);
				person.Permissions.Add(new OperationPermission()
				{
					Operation = "resources",
					Allow = true,
					Tags = {person.Id}
				});

				var resource = new Resource
				{
					Name = "resources",
					Id = "resources/1"
				};
				session.Store(resource);
				session.SetAuthorizationFor(resource, new DocumentAuthorization()
				{
					Tags = {"people/1"}
				});
				session.SaveChanges();
			}
			using (var session = store.OpenSession())
			{
				session.SecureFor("people/1", "resources/view");
				session.Load<Resource>("resources/1");
				var collection = session.Query<Resource>().ToList();
				Assert.NotEmpty(collection);
			}
			using(var session = store.OpenSession())
			{
				session.SecureFor("people/2", "resources/view");
				Assert.Throws<ReadVetoException>(() => session.Load<Resource>("resources/1"));
				var collection = session.Query<Resource>().ToList();
				Assert.Empty(collection);
			}
		}
Beispiel #23
0
        public void Add()
        {
            Person person = new Person(auth, clientId);

            try
            {
                 PersonDetails personDetails = new PersonDetails
                                {
                                    EmailAddress = "*****@*****.**",
                                    Name = "test",
                                    AccessLevel = 1023,
                                    Password = "******"
                                };

                person.Add(personDetails);
            }
            catch (CreatesendException ex)
            {
                ErrorResult error = (ErrorResult)ex.Data["ErrorResult"];
                Console.WriteLine(error.Code);
                Console.WriteLine(error.Message);
            }
            catch (Exception ex)
            {
                // Handle some other failure
                Console.WriteLine(ex.ToString());
            }
        }
        public void TestShortcutCreate()
        {
            string storeName = "TestShortcutCreate" + DateTime.Now.Ticks;
            string aliceId;
            using (var context = CreateEntityContext(storeName))
            {
                var sales = new Department(context) { Name = "Sales", DeptId = 1 };
                var bob = new Person(context) { Name = "Bob" };
                var alice = new Person(context) { Name = "Alice", Age = 54, Department = sales, Friends = new Collection<IPerson> { bob } };
                context.SaveChanges();
                aliceId = alice.Id;
            }

            using (var context = CreateEntityContext(storeName))
            {
                var alice = context.Persons.FirstOrDefault(x => x.Id == aliceId);
                Assert.IsNotNull(alice);
                Assert.AreEqual("Alice", alice.Name);
                Assert.AreEqual(54, alice.Age);
                Assert.IsNotNull(alice.Department);
                Assert.AreEqual("Sales", alice.Department.Name);
                Assert.AreEqual(1, alice.Friends.Count);
                Assert.AreEqual("Bob", alice.Friends.First().Name);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Read all persons from the Textfile
        /// </summary>
        /// <returns>Person object List, with all persons</returns>
        public IList<Person> ReadAllPersons()
        {
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            StringBuilder sb = new StringBuilder();
            string fileContent;

            using (StreamReader sr = new StreamReader(mydocpath + @"\AllTxtFiles.txt"))
            {
                fileContent = sr.ReadToEnd();
            }
            char[] splitter = { ';' };
            IList<string> personStringList = fileContent.Split(splitter);
            IList<Person> personList = new List<Person>();
            foreach (string personString in personStringList)
            {
                int space = personString.IndexOf(" ");
                if (space > 0)
                {
                    Person person = new Person();
                    person.FirstName = personString.Substring(space);
                    person.LastName = personString.Substring(0, space);
                    personList.Add(person);
                }
            }
            return personList;
        }
        public void Example()
        {
            #region Usage
            Person person = new Person
            {
                Name = "Nigal Newborn",
                Age = 1
            };

            string jsonIncludeNullValues = JsonConvert.SerializeObject(person, Formatting.Indented);

            Console.WriteLine(jsonIncludeNullValues);
            // {
            //   "Name": "Nigal Newborn",
            //   "Age": 1,
            //   "Partner": null,
            //   "Salary": null
            // }

            string jsonIgnoreNullValues = JsonConvert.SerializeObject(person, Formatting.Indented, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            Console.WriteLine(jsonIgnoreNullValues);
            // {
            //   "Name": "Nigal Newborn",
            //   "Age": 1
            // }
            #endregion
        }
Beispiel #27
0
        /// <summary>
        /// deletes a person from the textfile
        /// </summary>
        /// <param name="person">person to delete</param>
        public void deletePerson(Person person)
        {
            string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            StringBuilder sb = new StringBuilder();
            string fileContent;

            using (StreamReader sr = new StreamReader(mydocpath + @"\AllTxtFiles.txt"))
            {
                fileContent = sr.ReadToEnd();
            }
            char[] splitter = { ';' };
            IList<string> nameList = fileContent.Split(splitter);
            StringBuilder sbNew = new StringBuilder();
            foreach (string firstAndLastName in nameList)
            {
                if (!firstAndLastName.Equals(person.LastName + " " + person.FirstName))
                {
                    sb.Append(firstAndLastName);
                    sb.Append(";");
                }
            }

            using (StreamWriter outfile = new StreamWriter(mydocpath + @"\AllTxtFiles.txt"))
            {
                outfile.Write(sb.ToString());
            }
        }
    /// <summary>
    /// fires when Delete button is clicked
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteRecord(object sender, GridViewDeleteEventArgs e)
    {
        int personID = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());

        // instantiate BAL
        PersonBAL pBAL = new PersonBAL();
        Person person = new Person();
        try
        {
            person.PersonID = personID;
            pBAL.Delete(person);

            lblMessage.Text = "Record Deleted Successfully.";
        }
        catch (Exception ee)
        {
            lblMessage.Text = ee.Message.ToString();
        }
        finally
        {
            person = null;
            pBAL = null;
        }

        GridView1.EditIndex = -1;
        // Refresh the list
        BindGrid();
    }
Beispiel #29
0
 public Job(string filePath, JobParameterStruct jobParam, Person person)
 {
     this.jobParam = jobParam;
     this.filePath = filePath;
     this.fileName = Path.GetFileName(filePath);
     this.person = person;
 }
        public void Example()
        {
            #region Usage
            Person person = new Person
            {
                FirstName = "Dennis",
                LastName = "Deepwater-Diver"
            };

            string startingWithF = JsonConvert.SerializeObject(person, Formatting.Indented,
                new JsonSerializerSettings { ContractResolver = new DynamicContractResolver('F') });

            Console.WriteLine(startingWithF);
            // {
            //   "FirstName": "Dennis",
            //   "FullName": "Dennis Deepwater-Diver"
            // }

            string startingWithL = JsonConvert.SerializeObject(person, Formatting.Indented,
                new JsonSerializerSettings { ContractResolver = new DynamicContractResolver('L') });

            Console.WriteLine(startingWithL);
            // {
            //   "LastName": "Deepwater-Diver"
            // }
            #endregion
        }
 public WrappingModelWithProperty(Person person)
 {
     Person = person;
 }
Beispiel #32
0
 public void architecture_OnSelectprince(Person person, Person leader)//立储
 {
     Session.MainGame.mainGameScreen.Selectprince(person, leader);
 }
Beispiel #33
0
 public List <Skill> Skills(Person person, int?id) => _persons.GetSkills(person.Id, id);
Beispiel #34
0
 public void architecture_OnZhaoxian(Person person, Person leader)
 {
     Session.MainGame.mainGameScreen.Zhaoxian(person, leader);
 }
Beispiel #35
0
 public string FullName(Person person) => $"{person.Name} {person.Surname}";
Beispiel #36
0
 public List <Person> Friends(Person person, int?id) => _persons.GetFriends(person.Id, id);
Beispiel #37
0
 public Person PostPerson(string id, Person person)
 {
     person.Identifier = id;
     return person;
 }
Beispiel #38
0
 public Skill FavSkill(Person person) => _skills.Get(person.FavSkillId);
Beispiel #39
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            int errorCount = 0;

            #region 更新数据
            proj.DutyNormalUnit = txtProjectNormalUnit.Text;
            proj.copyTo(ConnectionManager.Context.table("Project")).where ("ProjectID='" + proj.ProjectID + "'").update();
            if (proj.DutyNormalUnit == "未匹配")
            {
                errorCount++;
            }

            foreach (DataRow dr in dtSubject.Rows)
            {
                string normalUnit = dr["row3"] != null ? dr["row3"].ToString() : string.Empty;
                string projectID  = dr["row4"] != null ? dr["row4"].ToString() : string.Empty;
                string subjectID  = dr["row5"] != null ? dr["row5"].ToString() : string.Empty;

                Subject subjectObj = ConnectionManager.Context.table("Subject").where ("SubjectID='" + subjectID + "' and ProjectID='" + projectID + "'").select("*").getItem <Subject>(new Subject());
                if (string.IsNullOrEmpty(subjectObj.SubjectID))
                {
                    continue;
                }

                subjectObj.DutyNormalUnit = normalUnit;
                subjectObj.copyTo(ConnectionManager.Context.table("Subject")).where ("SubjectID='" + subjectID + "' and ProjectID='" + projectID + "'").update();

                if (subjectObj.DutyNormalUnit == "未匹配")
                {
                    errorCount++;
                }
            }

            foreach (DataRow dr in dtPerson.Rows)
            {
                string normalUnit = dr["row4"] != null ? dr["row4"].ToString() : string.Empty;
                string projectID  = dr["row5"] != null ? dr["row5"].ToString() : string.Empty;
                string personID   = dr["row6"] != null ? dr["row6"].ToString() : string.Empty;

                Person personObj = ConnectionManager.Context.table("Person").where ("PersonID='" + personID + "' and ProjectID='" + projectID + "'").select("*").getItem <Person>(new Person());
                if (string.IsNullOrEmpty(personObj.PersonID))
                {
                    continue;
                }

                personObj.WorkNormalUnit = normalUnit;
                personObj.copyTo(ConnectionManager.Context.table("Person")).where ("PersonID='" + personID + "' and ProjectID='" + projectID + "'").update();

                if (personObj.WorkNormalUnit == "未匹配")
                {
                    errorCount++;
                }
            }
            #endregion

            Catalog catalog = ConnectionManager.Context.table("Catalog").where ("CatalogID='" + proj.CatalogID + "'").select("*").getItem <Catalog>(new Catalog());
            catalog.IsCheckUnitComplete = errorCount == 0 ? "通过" : "不通过";
            proj.IsCheckUnitComplete    = errorCount == 0 ? "通过" : "不通过";

            proj.copyTo(ConnectionManager.Context.table("Project")).where ("ProjectID='" + proj.ProjectID + "'").update();
            catalog.copyTo(ConnectionManager.Context.table("Catalog")).where ("CatalogID='" + catalog.CatalogID + "'").update();

            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
        public void CallPostedToByteArrayMethodOfFileConverter_WhenModelStateIsValidAndThereAreFilesInTheRequest()
        {
            // Arrange
            var genreServiceMock  = new Mock <IGenreService>();
            var movieServiceMock  = new Mock <IMovieService>();
            var personServiceMock = new Mock <IPersonService>();
            var fileConverterMock = new Mock <IFileConverter>();
            var mapperMock        = new Mock <IMapper>();

            var personViewModel = new PersonViewModel()
            {
                FirstName   = "Ivan",
                LastName    = "Stanev",
                Nationality = "Bulgarian",
                DateOfBirth = DateTime.UtcNow,
                Gender      = Gender.Male
            };

            var personDbModel = new Person()
            {
                FirstName   = personViewModel.FirstName,
                LastName    = personViewModel.LastName,
                Nationality = personViewModel.Nationality,
                DateOfBirth = personViewModel.DateOfBirth,
                Gender      = personViewModel.Gender
            };

            var validationContext =
                new System.ComponentModel.DataAnnotations.ValidationContext(personViewModel, null, null);

            var results = new List <ValidationResult>();

            var isModelValid = Validator.TryValidateObject(personViewModel, validationContext, results);

            mapperMock.Setup(x => x.Map <Person>(personViewModel)).Returns(personDbModel);

            var panelController = new PanelController(
                genreServiceMock.Object,
                movieServiceMock.Object,
                personServiceMock.Object,
                fileConverterMock.Object,
                mapperMock.Object);

            var contextMock = new Mock <HttpContextBase>();
            var requestMock = new Mock <HttpRequestBase>();
            var filesMock   = new Mock <HttpFileCollectionBase>();
            var pictureMock = new Mock <HttpPostedFileBase>();

            contextMock.Setup(c => c.Request).Returns(requestMock.Object);
            filesMock.Setup(f => f.Count).Returns(1);
            filesMock.Setup(f => f["Picture"]).Returns(pictureMock.Object);
            requestMock.Setup(r => r.Files).Returns(filesMock.Object);
            panelController.ControllerContext =
                new ControllerContext(contextMock.Object, new RouteData(), panelController);

            // Act
            panelController.AddPerson(personViewModel);

            // Assert
            Assert.IsTrue(isModelValid);
            fileConverterMock.Verify(fcm => fcm.PostedToByteArray(pictureMock.Object), Times.Once);
        }
Beispiel #41
0
        public void addPerson(Person p)
        {
            var people = _database.GetCollection <BsonDocument>("people");

            people.InsertOne(p.ToBsonDocument());
        }
Beispiel #42
0
        public static void CreateFirstUser(string name, string mail, string password)
        {
            // Make sure that no first person exists already, as a security measure

            try
            {
                Person personOne       = null;
                bool   personOneExists = false;

                try
                {
                    personOne = Person.FromIdentity(1);
                    if (Debugger.IsAttached)
                    {
                        if (personOne.CityName != "Duckville" || personOne.Mail != "*****@*****.**")
                        // these values are returned in debug environments when no person is found
                        {
                            personOneExists = true;
                        }
                        else
                        {
                            personOne = null;
                        }
                    }
                    else
                    {
                        personOneExists = true;
                    }
                }
                catch (Exception)
                {
                    // We expect this to throw.
                }

                if (personOneExists || personOne != null)
                {
                    throw new InvalidOperationException("Cannot run initialization processes again when initialized.");
                }

                Person newPerson = Person.Create(name, mail, password, string.Empty, string.Empty, string.Empty,
                                                 string.Empty, string.Empty, new DateTime(1972, 1, 21), PersonGender.Unknown);

                // Add membership in Sandbox
                newPerson.AddParticipation(Organization.Sandbox, Constants.DateTimeHigh); // expires never

                // Initialize staffing to System and Sandbox with the new user
                Positions.CreateSysadminPositions();

                Positions.ForOrganization(Organization.Sandbox).AtLevel(PositionLevel.OrganizationExecutive)[0].Assign(
                    newPerson, null /* assignedByPerson */, null /* assignedByPosition */, "Initial Sandbox executive",
                    null /* expires */);
            }
            catch (Exception exception)
            {
                try
                {
                    SwarmDb.GetDatabaseForWriting().CreateExceptionLogEntry(DateTime.UtcNow, "Initialization", exception);
                    throw;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }