예제 #1
0
        //public IEnumerable<Person> getPersons([FromBody]SearchParams param)
        public IEnumerable <Person> getPersons(string searchString)
        {
            IEnumerable <Person> ret = null;

            searchString = JsonConvert.DeserializeObject <string>(searchString);

            //searchString = searchString.Replace('\\\','');

            try
            {
                using (var db = new PeopleDB())
                {
                    ret = db.GetPersonsBySearch(searchString)
                          .Select(p => new Person
                    {
                        FirstName = p.FirstName,
                        LastName  = p.LastName,
                        Age       = p.Age,
                        Address   = p.Address,
                        Interests = p.Interests,
                        Picture   = p.Picture
                    })
                          .ToList();

                    return(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
    private void Awake()
    {
        //if there are any other instances of PeopleDB in a scene, destroy them and make this the only one
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != null)
        {
            Destroy(gameObject);
        }

        //begin reading people from the XML sheet
        ReadItemsFromDatabase();

        //debug tools -- turn every person in the newly made dictionary into a Person class
        for (int i = 0; i < peopleDictionaries.Count; i++)
        {
            people.Add(new Person(peopleDictionaries[i]));

            foreach (Person person in people)
            {
            }
        }

        //make this database persist throughout the game
        DontDestroyOnLoad(gameObject);
    }
 public PeopleRepository(PeopleDB context, PurchasesDB contextPurchases, SendEmailsDB contextSendEmails, SendTextMessagesDB contextSendTextMessages)
 {
     _context                 = context;
     _contextPurchases        = contextPurchases;
     _contextSendEmails       = contextSendEmails;
     _contextSendTextMessages = contextSendTextMessages;
 }
예제 #4
0
        public IActionResult EditPerson(Person p)
        {
            var db = new PeopleDB(_connectionString);

            db.EditPerson(p);
            return(Json(p));
        }
예제 #5
0
        public IActionResult DeletePerson(int id)
        {
            var db = new PeopleDB(_connectionString);

            db.DeletePerson(id);
            return(Json(id));
        }
예제 #6
0
        public IActionResult GetPeople()
        {
            var db  = new PeopleDB(_connectionString);
            var ppl = db.GetPeople();

            return(Json(ppl));
        }
 public LanguagesRepository(LanguagesDB context, AccusationsDB contextAccusations, ComplementsDB contextComplements, FarewellsDB contextFarewells, GreetingsDB contextGreetings, InvitationsOffersDB contextInvitationsOffers, PeopleDB contextPeople, RequestsForActionDB contextRequestsForAction, RequestsForInformationDB contextRequestsForInformation)
 {
     _context                       = context;
     _contextAccusations            = contextAccusations;
     _contextComplements            = contextComplements;
     _contextFarewells              = contextFarewells;
     _contextGreetings              = contextGreetings;
     _contextInvitationsOffers      = contextInvitationsOffers;
     _contextPeople                 = contextPeople;
     _contextRequestsForAction      = contextRequestsForAction;
     _contextRequestsForInformation = contextRequestsForInformation;
 }
예제 #8
0
        public IActionResult Index()
        {
            PeopleDB        db = new PeopleDB(_connectionString);
            PersonViewModel vm = new PersonViewModel
            {
                people = db.GetPeople()
            };

            if (TempData["message"] != null)
            {
                vm.Message = (string)TempData["message"];
            }
            return(View(vm));
        }
예제 #9
0
        public ActionResult UpdatePerson(int id, string region)
        {
            try
            {
                // 수정할 데이터를 선택합니다.
                var peopleDB   = new PeopleDB();
                var willUpdate = peopleDB.People.Single(x => x.Id == id);

                // 수정합니다.
                willUpdate.Region = region;
                peopleDB.SubmitChanges();
                return(Content("UPDATE SUCCESS"));
            }
            catch (Exception exception)
            {
                return(HttpNotFound());
            }
        }
예제 #10
0
        public ActionResult DeletePerson(int id)
        {
            try
            {
                // 삭제할 데이터를 선택합니다.
                var peopleDB   = new PeopleDB();
                var willDelete = peopleDB.People.Single(x => x.Id == id);


                // 삭제합니다.
                peopleDB.People.DeleteOnSubmit(willDelete);
                peopleDB.SubmitChanges();
                return(Content("DELETE SUCCESS"));
            }
            catch (Exception excception)
            {
                return(HttpNotFound());
            }
        }
예제 #11
0
        public ActionResult InsertPerson(string name, string gender, string region, string bloodType)
        {
            // 테이블에 입력할 데이터를 만듭니다.
            var willAdd = new People();

            willAdd.Name      = name;
            willAdd.Gender    = gender;
            willAdd.Region    = region;
            willAdd.BloodType = bloodType;
            try
            {
                // 테이블에 데이터를 집어넣습니다.
                var peopleDB = new PeopleDB();
                peopleDB.People.InsertOnSubmit(willAdd);
                peopleDB.SubmitChanges();
                return(Content("INSERT SUCCESS"));
            }
            catch (Exception exception)
            {
                // 데이터 입력에 실패할 경우
                return(HttpNotFound());
            }
        }
예제 #12
0
 public void TestInit()
 {
     this.sut = new PeopleDB(new Person(123456789, "Gosho"), new Person(987654321, "Pesho"));
 }
예제 #13
0
        public ActionResult GetPeopleJSON()
        {
            var peopleDB = new PeopleDB();

            return(Json(peopleDB.People, JsonRequestBehavior.AllowGet));
        }