예제 #1
0
        public void Run()
        {
            Person realPerson = new Person();

            realPerson.Name      = "Jeff";
            realPerson.Age       = 10;
            realPerson.IsMarried = false;

            Person personTwo = new Person("Austin", 25, false);

            Console.WriteLine(personTwo.IsMarried);
            Console.ReadKey();

            Person personThree = new Person("Mike", 4, true);

            PersonRepository repo = new PersonRepository();

            repo.AddPerson(realPerson);
            repo.AddPerson(personTwo);
            repo.AddPerson(personThree);

            List <Person> returnList = repo.ReturnPerson();

            int num = returnList.Count();

            Console.WriteLine(num);


            Console.ReadLine();
        }
예제 #2
0
        public void Run()
        {
            Person personOne = new Person(); // This is calling to the original empty Person constructor in our Person class

            personOne.Name      = "Adam";    // Adam is a real value being held inside Name property for personOne  // expressions in code work from right to left
            personOne.Age       = 30;
            personOne.IsMarried = true;


            Person personTwo = new Person("Christa", 40, true);  //Fill out actual values found in overloaded Person constructor

            Console.WriteLine(personTwo.IsMarried);
            Console.ReadKey();


            PersonRepository _repo = new PersonRepository(); // repo is a PersonRepository object that we named repo

            _repo.AddPerson(personOne);                      // This puts personOne inside of listOfPeople
            _repo.AddPerson(personTwo);

            List <Person> localList = _repo.ReturnList();   // need to hold what this method returns to a variable

            int number = localList.Count();

            Console.WriteLine(number);
        }
예제 #3
0
        public void Run()
        {
            Person personOne = new Person();

            personOne.Name      = "Jeff";
            personOne.Age       = 10;
            personOne.IsMarried = true;

            Person personTwo = new Person("Christa", 11, true);

            Console.WriteLine(personTwo.IsMarried);


            PersonRepository _repo = new PersonRepository();

            _repo.AddPerson(personOne);
            _repo.AddPerson(personTwo);

            List <Person> localList = _repo.ReturnList();

            int number = localList.Count();

            Console.WriteLine(number);
            Console.ReadKey();
        }
예제 #4
0
        /// <summary>
        /// Проверяет наличие пользователей в системе
        /// </summary>
        private void FirstStart()
        {
            ModelContainer cont = new ModelContainer();

            PersonRepository personRepository = new PersonRepository(cont);

            if (cont.Person == null || cont.Person.Count() == 0)
            {
                personRepository.AddPerson("Менеджер", "Менеджер", "Менеджер",
                                           "Manager", "Manager", (int)Position.Менеджер, "", "");

                personRepository.AddPerson("Исполнитель", "Исполнитель", "Исполнитель",
                                           "User", "User", (int)Position.Исполнитель, "*****@*****.**", "");
            }
        }
예제 #5
0
        public void TestAddPerson()
        {
            var gp  = new GenotypeRepository();
            var j   = new Person("Jess Potts", Sex.Female, true, gp);
            var e   = new Person("Erica Korner", Sex.Female, true, gp);
            var p   = new Person("paul Korner", Sex.Female, true, gp);
            var rep = new PersonRepository();

            rep.AddPerson(j);
            rep.AddPerson(e);
            var result = rep.ListPersons();

            Assert.IsTrue(result.Contains(j));
            Assert.IsTrue(result.Contains(e));
            Assert.IsFalse(result.Contains(p));
        }
예제 #6
0
        public ActionResult Add(Person person)
        {
            var db = new PersonRepository(Properties.Settings.Default.ConStr);

            db.AddPerson(person);
            return(Json(person));
        }
예제 #7
0
        public PersonController()
        {
            if (PersonRepository.PersonList.Count == 0)
            {
                Person admin = new Person()
                {
                    Name     = "Corey Clark",
                    Position = "Admin",
                    About    = "This is something interesting about me."
                };
                PersonRepository.AddPerson(admin);

                Person newPerson1 = new Person()
                {
                    Name     = "Betty Lou",
                    Position = "Dev Grunt",
                    About    = "I also just work here."
                };
                PersonRepository.AddPerson(newPerson1);

                Person newPerson2 = new Person()
                {
                    Name     = "Addy Ministrader",
                    Position = "Admin",
                    About    = "I just work here."
                };
                PersonRepository.AddPerson(newPerson2);
            }
        }
        public ActionResult AddPerson(Person person)
        {
            var repo = new PersonRepository(Properties.Settings.Default.ConStr);

            repo.AddPerson(person);
            return(RedirectToAction("Index"));
        }
예제 #9
0
        private void AddPerson(object obj)
        {
            Person newPerson = new Person();
            var    viewmodel = new PersonViewModel
            {
                Name = string.Empty,
            };
            AddPersonView addListView = new AddPersonView {
                DataContext = viewmodel
            };

            addListView.ShowDialog();
            if (viewmodel.IsConfirm)
            {
                var exist = db.DownloadList(viewmodel.Name);
                if (exist != null)
                {
                    MessageBox.Show("Istnieje już taka osoba!");
                    return;
                }
                newPerson.Name = viewmodel.Name;

                var date = viewmodel.DayOfBirth.Date;
                newPerson.BirthDate = date.ToString("d");
                date = viewmodel.DayOfDeath.Date;
                newPerson.DeathDate = date.ToString("d");
                newPerson.Gender    = viewmodel.Gender.ToString();
                var res = db.AddPerson(newPerson);
                if (res == false)
                {
                    MessageBox.Show("Wystąpił błąd przy dodawaniu!");
                }
                Refresh();
            }
        }
예제 #10
0
        public void AddPerson(Person person)
        {
            ValidatePerson(person);

            _personRepository.AddPerson(person);

            MessageBox.Show($"\"{person.FullName}\" sucessfully added!", "Person added", MessageBoxButton.OK, MessageBoxImage.Information);
        }
예제 #11
0
        static void Main(string[] args)
        {
            //Currency Test
            CurrencyRepository currencyRepo = new CurrencyRepository();
            Currency           EUR          = currencyRepo.GetCurrencyWithName("EUR");



            //Trip Test
            PersonRepository repo = new PersonRepository();

            repo.AddPerson("Pieter");
            repo.AddPerson("Margaux");
            Person Pieter  = repo.GetPerson(0);
            Person Margaux = repo.GetPerson(1);

            TripRepository tripRepo = new TripRepository();

            tripRepo.AddTrip("Parijs", EUR);
            Trip Parijs = tripRepo.GetTrip(0);

            Parijs.AddPersonToTrip(Pieter);
            Parijs.AddPersonToTrip(Margaux);

            // "m" == decimal number
            Expense Resto = new Expense(Pieter, Parijs, EUR);

            Resto.AddItem("Pasta", 8.05m, Pieter);
            Resto.AddItem("Pasta", 8.05m, Margaux);
            Resto.AddItem("Wine", 8.05m, Margaux);
            Resto.AddItem("Ice cream", 5.00m, Margaux);
            Parijs.AddExpenseToTrip(Resto);

            Expense Museum = new Expense(Margaux, Parijs, EUR);

            Museum.AddItem("Entry", 12m, Pieter);
            Museum.AddItem("Entry", 12m, Margaux);
            Parijs.AddExpenseToTrip(Museum);

            Pieter.AddTransaction(Margaux, 2);

            var owes = Pieter.GetOwesPersonInCurrency(currencyRepo.GetCurrencyWithName("EUR"));

            Console.WriteLine("");
        }
예제 #12
0
        static void Main(string[] args)
        {
            PersonRepository repository = new PersonRepository(new PeopleContext());

            repository.AddPerson(new Person {
                FirstName = "Johny", LastName = "Wolf"
            });
            repository.Update();
        }
예제 #13
0
        public IHttpActionResult Post([FromBody] Person person)
        {
            if (ModelState.IsValid)
            {
                repo.AddPerson(person);
                return(Ok("Person added to PersonDB!"));
            }

            return(BadRequest("Something went horribly wrong!"));
        }
예제 #14
0
        public void TestReturnPerson()
        {
            var gp  = new GenotypeRepository();
            var j   = new Person("Jess Potts", Sex.Female, true, gp);
            var e   = new Person("Erica Korner", Sex.Female, true, gp);
            var p   = new Person("Paul Korner", Sex.Female, true, gp);
            var rep = new PersonRepository();

            rep.AddPerson(j);
            rep.AddPerson(e);

            var testList = new List <Person>();

            testList.Add(j);
            testList.Add(e);
            var result = rep.ListPersons();

            CollectionAssert.AreEqual(testList, result);
        }
예제 #15
0
 /// <summary>
 /// 添加人员
 /// </summary>
 /// <param name="dto">添加人员信息</param>
 /// <returns></returns>
 public HttpResponseMessage Post(AddPersonDTO personDTO)
 {
     try
     {
         return(ResponseWrapper.SuccessResponse(repository.AddPerson(personDTO, p => true)));
     }
     catch (Exception e)
     {
         return(ResponseWrapper.ExceptionResponse(e));
     }
 }
예제 #16
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            var p = new Person();

            PersonRepository.AddPerson(p);

            var window = new MainWindow();

            window.DataContext = p;
            window.Show();
        }
예제 #17
0
        public IActionResult AddPerson(Person person)
        {
            if (ModelState.IsValid)
            {
                people.AddPerson(person);

                return(RedirectToAction("ShowPerson"));
            }
            else
            {
                return(View(person));
            }
        }
예제 #18
0
 /// <summary>
 /// 添加人员
 /// </summary>
 /// <param name="dto">添加人员信息</param>
 /// <returns></returns>
 public HttpResponseMessage Post(AddPersonDTO personDTO)
 {
     try
     {
         var user   = UserHelper.GetCurrentUser();
         var person = repository.AddPerson(personDTO, p => p.InstituteId == user.InstId);
         return(ResponseWrapper.SuccessResponse(person));
     }
     catch (Exception e)
     {
         return(ResponseWrapper.ExceptionResponse(e));
     }
 }
    public void SubmitPerson()
    {
        string           name = PersonName.text;
        PersonRepository repo = GetComponent <PersonRepository>();

        repo.AddPerson(name);

        PersonList personList = GetComponent <PersonList>();

        personList.Prime();

        PersonName.text           = "";
        invalidPersonName.text    = "";
        submitButton.interactable = false;
    }
예제 #20
0
        public HttpResponseMessage Register(PersonDTO User)
        {
            using (HttpClient http = new HttpClient())
            {
                this.Request.RequestUri = new Uri("http://localhost:65192");

                if (this.Request.Method == HttpMethod.Get)
                {
                    this.Request.Content = null;
                }

                _PersonRepository.AddPerson(User);

                return(Request.CreateResponse(HttpStatusCode.OK, Configuration.Formatters.JsonFormatter));
            }
        }
예제 #21
0
        public void TestMethod1()
        {
            //AAA
            //Arrange
            PersonRepository repo       = new PersonRepository();
            Person           realPerson = new Person();

            //ACT   -Using our methods
            repo.AddPerson(realPerson);
            List <Person> returnList = repo.ReturnPerson();
            //ASSERT
            int expected = 1;
            int actual   = returnList.Count();

            Assert.AreEqual(expected, actual);
        }
예제 #22
0
        private static void AddPersonScreen(PersonRepository personRepository, GenotypeRepository genotypeRepository)
        {
            Console.Clear();
            try
            {
                Console.WriteLine("Name (first and last): ");
                string inputName = Console.ReadLine();
                if (inputName == null || inputName == " ")
                {
                    throw new Exception();
                }

                Console.WriteLine("Sex ( Male or Female ): ");
                string inputtedSex = Console.ReadLine();
                if (inputtedSex == null)
                {
                    throw new Exception();
                }
                Sex inputSex = (Sex)Enum.Parse(typeof(Sex), inputtedSex, true);
                if (inputSex == Sex.Female || inputSex == Sex.Male || inputSex == Sex.Unknown)
                {
                    Console.WriteLine("Living (true or false): ");
                    string acceptableTrueString  = "true";
                    string acceptableFalseString = "false";
                    string inputtedLiving        = Console.ReadLine();
                    if (inputtedLiving == acceptableTrueString || inputtedLiving == acceptableFalseString)
                    {
                        bool inputLiving = (bool)Convert.ToBoolean(inputtedLiving);
                        personRepository.AddPerson(inputName, inputSex, inputLiving, "unaffected");
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Input was not valid, press any button to try again.");
                Console.ReadLine();
                AddPersonScreen(personRepository, genotypeRepository);
            }
        }
예제 #23
0
 public ActionResult Create(IFormCollection collection)
 {
     try
     {
         var personsRepo = new PersonRepository();
         var personDTO   = new PersonDTO();
         personDTO.Name     = collection["Name"];
         personDTO.Surname  = collection["Surname"];
         personDTO.IdNumber = collection["IdNumber"];
         var result = personsRepo.AddPerson(personDTO);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #24
0
        public async Task <IActionResult> Post([FromBody] PersonModel personModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await _personRepository.AddPerson(_mapper.Map <PersonEntity>(personModel));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure " + ex.Message));
            }
            return(Ok());
        }
예제 #25
0
        static void Main(string[] args)
        {
            ConnectionFactory factory = new ConnectionFactory();

            factory.Uri = new System.Uri("amqp://*****:*****@localhost:5672");

            IConnection conn    = factory.CreateConnection();
            IModel      channel = conn.CreateModel();

            channel.QueueDeclare("queue",
                                 durable: true,
                                 autoDelete: false,
                                 arguments: null,
                                 exclusive: false
                                 );

            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (sender, e) =>
            {
                var body       = e.Body.ToArray();
                var personData = Encoding.UTF8.GetString(body);
                var _person    = JsonConvert.DeserializeObject <Person>(personData);

                IPersonDatabaseSettings pds = new PersonDatabaseSettings
                {
                    ConnectionString = "mongodb://localhost:27017",
                    DatabaseName     = "UserDb",
                    CollectionName   = "Person"
                };
                try
                {
                    PersonRepository repo = new PersonRepository(pds);
                    var isAdded           = repo.AddPerson(_person).Result;
                    Console.WriteLine(isAdded);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            };
            channel.BasicConsume("queue", true, consumer);
            Console.ReadLine();
            channel.Close();
            conn.Close();
        }
예제 #26
0
        public void TestMethod1_AddPerson()  // Method to test a method - Declare which method you are testing so you know
        {
            // AAA

            // Arrange
            PersonRepository _repo     = new PersonRepository(); // How do you access it? Create a new instance of PersonRepository
            Person           personOne = new Person();           // What does this method need? Person

            // Act - this portion of the test is using our method.
            _repo.AddPerson(personOne);
            List <Person> localList = _repo.ReturnList();  // because list returns something, want to save it to a variable to make it easier to access

            // Assert - How do I know if this method (AddPerson) worked?
            int expected = 1;
            int actual   = localList.Count;

            Assert.AreEqual(expected, actual);
        }
        public void TestMethod1_AddPerson()
        {
            //AAA

            //Arrange
            PersonRepository _repo   = new PersonRepository();
            Person           person1 = new Person();

            //Act
            _repo.AddPerson(person1);
            List <Person> localList = _repo.ReturnList();


            //Assert
            int expected = 1;
            int actual   = localList.Count;

            Assert.AreEqual(expected, actual);
        }
예제 #28
0
 public ActionResult Post(Person person)
 {
     PersonRepository.AddPerson(person);
     return(Ok());
 }
예제 #29
0
 public ActionResult SayHello(Person person)
 {
     PersonRepository.AddPerson(person);
     return(View(person));
 }
예제 #30
0
 public void AddPersonTest()
 {
     PersonRepository.AddPerson(new Person());
 }