static void Main(string[] args)
        {
            List <Person> _persons = new List <Person>()
            {
                new Person()
                {
                    Id = 1, Name = "Joe"
                },
                new Person()
                {
                    Id = 2, Name = "James"
                },
                new Person()
                {
                    Id = 3, Name = "Nick"
                },
                new Person()
                {
                    Id = 4, Name = "Mike"
                },
                new Person()
                {
                    Id = 5, Name = "John"
                },
            };

            PersonHandler _personHandler = (Person person) => person.Id.ToString();

            IEnumerable <string> _personIds = _persons.Select(p => _personHandler.Invoke(p));

            foreach (var id in _personIds)
            {
                Console.WriteLine(string.Format("Id's : {0}", id));
            }
        }
Beispiel #2
0
        public void ConstructorTest()
        {
            PersonHandler ph = new PersonHandler(data);

            Assert.Equal(500, ph.People.Count);
            Assert.Equal("Arlinda", ph.People.ElementAt(462).FirstName);
        }
 public PersonsViewModel()
 {
     Persons       = new ObservableCollection <Person>();
     PersonHandler = new PersonHandler(this);
     _addCommand   = new RelayCommand(PersonHandler.AddPersons);
     _saveCommand  = new RelayCommand(PersonHandler.SavePersonsAsync);
     _loadCommand  = new RelayCommand(PersonHandler.LoadPersonsAsync);
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Application running press ENTER to terminate...");

            //Starts the PersonHandler
            PersonHandler sh = new PersonHandler();

            Console.ReadLine();
        }
Beispiel #5
0
        public void TestConstructor()
        {
            PersonHandler ph = new PersonHandler(data);

            Assert.AreEqual(500, ph.People.Count);
            //Assert.AreEqual("Arlinda", ph.People.ElementAt(463).FirstName);
            //Assert.AreEqual("Tim", ph.People.ElementAt(463).FirstName);
            //Assert.AreEqual("Baird", ph.People.ElementAt(463).Surname);
        }
Beispiel #6
0
        public void TestGetAmountBornOnEachDate()
        {
            PersonHandler ph = new PersonHandler(data);

            var result = ph.GetAmountBornOnEachDate();

            Assert.Equal("11/04/2017 2", result.First());
            Assert.Equal("08/05/2017 1", result[23]);
        }
Beispiel #7
0
        public void TestGetOrderBySurname()
        {
            PersonHandler ph = new PersonHandler(data);

            var ordered = ph.GetOrderBySurname();

            Assert.Equal(500, ordered.Count);
            Assert.Equal("Aarons", ordered[0].Surname);
            Assert.Equal("Zarb", ordered[ordered.Count - 1].Surname);
        }
Beispiel #8
0
        public ActionResult GetTimesByPerson(int id)
        {
            var person = PersonHandler.Select(id);
            var db     = BusinessLayer as DbTimeHandler;
            var times  = db.GetTimesByPeople(new List <PersonDTO>()
            {
                person
            });

            return(Json(times));
        }
Beispiel #9
0
        public void TestGetNumSurnameBegins()
        {
            PersonHandler ph = new PersonHandler(data);

            Assert.Equal(24, ph.GetNumSurnameBegins("A", true));
            Assert.Equal(24, ph.GetNumSurnameBegins("a", false));
            Assert.Equal(0, ph.GetNumSurnameBegins("a", true));

            Assert.Equal(0, ph.GetNumSurnameBegins("tA", true));
            Assert.Equal(1, ph.GetNumSurnameBegins("tA", false));
        }
Beispiel #10
0
        public void PersonHandler_CreatePerson_LName_To_Big_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            //Person newPerson = personHandler.CreatePerson(33, "Stina", "Andersson", 165.5, 62.5);

            // Act
            // actual
            Assert.Throws <ArgumentException>(() => personHandler.CreatePerson(33, "Stina", "1234567890123456", 165.5, 62.5));
        }
Beispiel #11
0
        public void PersonHandler_CreatePerson_FName_Null_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            //Person newPerson = personHandler.CreatePerson(33, "Stina", "Andersson", 165.5, 62.5);

            // Act
            // actual
            Assert.Throws <ArgumentNullException>(() => personHandler.CreatePerson(33, null, "Andersson", 165.5, 62.5));
        }
Beispiel #12
0
        public void PersonHandler_CreatePerson_Wrong_Age_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            //Person newPerson = personHandler.CreatePerson(0, "Stina", "Andersson", 165.5, 62.5);

            // Act
            // actual
            Assert.Throws <ArgumentException>(() => personHandler.CreatePerson(0, "Stina", "Andersson", 165.5, 62.5));
        }
        public static List <int> GetRoleList()
        {
            var userID = Digimaker.User.Identity.ID;
            var data   = PersonHandler.GetAccessRoles(userID);
            var roles  = new List <int>();

            foreach (DataRow row in data.AccessRole.Rows)
            {
                roles.Add(Int32.Parse(row["RoleID"].ToString()));
            }
            return(roles);
        }
Beispiel #14
0
        public void PersonHandler_SetHeight_Person_Null()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual

            // Assert
            Assert.Throws <ArgumentNullException>(() => personHandler.SetHeight(null, 12.3));
        }
Beispiel #15
0
        public void PersonHandler_SetAge_Person_Argument_null_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual

            // Assert
            Assert.Throws <ArgumentNullException>(() => personHandler.SetAge(null, 44));
        }
Beispiel #16
0
        public void PersonHandler_SetAge_Age_Is_0_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual

            // Assert
            Assert.Throws <ArgumentException>(() => personHandler.SetAge(person, 0));
        }
Beispiel #17
0
        public void PersonHandler_SetName_LName_With_null_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual

            // Assert
            Assert.Throws <ArgumentNullException>(() => personHandler.SetName(person, "Berit", null));
        }
Beispiel #18
0
        public void PersonHandler_SetName_LName_With_To_Big_FName_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual

            // Assert
            Assert.Throws <ArgumentException>(() => personHandler.SetName(person, "Berit", "1234567890123456"));
        }
Beispiel #19
0
        public void PersonHandler_SetName_FName_With_To_Small_FName_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual

            // Assert
            Assert.Throws <ArgumentException>(() => personHandler.SetName(person, "1", "Nilsson"));
        }
Beispiel #20
0
        public void PersonHandler_SetName_Person_Null_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual

            // Assert
            Assert.Throws <ArgumentNullException>(() => personHandler.SetName(null, "Berit", "Nilsson"));
        }
Beispiel #21
0
        public ActionResult GetChartsForPerson(int id)
        {
            var factory = new ChartFactory();
            var person  = PersonHandler.Select(id);
            var db      = BusinessLayer as DbTimeHandler;
            var times   = db.GetTimesByPeople(new List <PersonDTO>()
            {
                person
            });
            var charts = factory.CreateChartDataModels_Person(times);

            return(Json(charts, JsonRequestBehavior.AllowGet));
        }
        public void TestGetString()
        {
            PersonHandler ph = new PersonHandler(data);

            string expected = "Thornton Mynett 2/05/2017 12:00:00 AM/5/2017";
            string result   = ph.GetString(368);

            Assert.AreEqual(expected, result);

            expected = "Elianore Wyley 10/11/2017 12:00:00 AM/11/2017";
            result   = ph.GetString(85);
            Assert.AreEqual(expected, result);
        }
Beispiel #23
0
        public void PersonHandler_SetWeight_Person_Null_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            // Act
            // actual
            double dblActualWeight = person.Weight;

            // Assert
            Assert.Throws <ArgumentNullException>(() => personHandler.SetWeight(null, 78.3));
        }
Beispiel #24
0
        public void TestGetString()
        {
            PersonHandler ph = new PersonHandler(data);

            string expected = "Thornton Mynett 02/05/2017";
            string result   = ph.People[367].ToString();

            Assert.Equal(expected, result);

            expected = "Elianore Wyley 10/11/2017";
            result   = ph.People[84].ToString();
            Assert.Equal(expected, result);
        }
Beispiel #25
0
 public ActionResult GetHighScoreForPersonForDiscipline(int personId, int disciplineId)
 {
     try
     {
         var person     = PersonHandler.Select(personId);
         var discipline = DisciplineHandler.Select(disciplineId);
         var highscore  = ((DbTimeHandler)BusinessLayer).GetHighscoreForPersonForDiscipline(person, discipline);
         return(Json(highscore, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
         return(Json(e.Message, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #26
0
        public void PersonHandler_SetAge_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            personHandler.SetAge(person, 44);

            // Act
            // actual
            int iActualAge = person.Age;

            // Assert
            Assert.AreEqual(44, iActualAge);
        }
Beispiel #27
0
        public void PersonHandler_SetWeight_Test()
        {
            // Arrange
            // expected
            PersonHandler personHandler = new PersonHandler();

            personHandler.SetWeight(person, 12.3);

            // Act
            // actual
            double dblActualWeight = person.Weight;

            // Assert
            Assert.AreEqual(12.3, dblActualWeight);
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Ingrese un nombre");
                string nombre = Console.ReadLine();

                PersonHandler.Add(nombre, "");

                foreach (var person in PersonHandler.GetPeople())
                {
                    Console.WriteLine($"Person {person.Name}");
                }
            }
        }
Beispiel #29
0
        protected override DbObjDTO GetDtoFromCollection(int id, FormCollection collection)
        {
            var time = new TimeDTO
            {
                Pk      = id,
                FK_D    = int.Parse(collection["FK_D"]),
                FK_P    = int.Parse(collection["FK_P"]),
                Date    = Convert.ToDateTime(collection["Date"]),
                Seconds = decimal.Parse(collection["Seconds"])
            };

            time.Person     = PersonHandler.Select(time.FK_P);
            time.Discipline = DisciplineHandler.Select(time.FK_D);

            return(time);
        }
Beispiel #30
0
        public ActionResult Wizard(int id)
        {
            var discipline = DisciplineHandler.Select(id);
            var people     = PersonHandler.GetAll();

            var model = new InsertTimesByDisciplineModel
            {
                ControllerName = "Disciplines",
                Title          = "Disciplines",
                Discipline     = discipline,
                People         = people
            };

            ViewBag.Title = "Wizard, magic n'shit";
            return(View("~/Views/DbObjViews/Times/CreateWizard.cshtml", model));
        }
Beispiel #31
0
 public PersonsForm(Person person, PersonHandler pHandler, PersonsHandler psHandler, Apartment apartment, string pFindLName)
     : this()
 {
     this.perHandler = pHandler;
     this.persHandler = psHandler;
     this.per = person;
     this.perFindLName = pFindLName;
     this.m_apartment = apartment;
 }