예제 #1
0
        private int AddPerson(Person testPerson)
        {
            dbContext.People.Add(testPerson);

            dbContext.SaveChanges();

            return(testPerson.PersonId);
        }
예제 #2
0
        public ActionResult AddPerson([FromBody] Person req)
        {
            AccelaDbContext dbContext = new AccelaDbContext();

            dbContext.People.Add(req);
            dbContext.SaveChanges();

            return(Ok());
        }
예제 #3
0
        public ActionResult DeleteReport(int personId)
        {
            AccelaDbContext dbContext = new AccelaDbContext();

            Person personToRemove = dbContext.People.Where(x => x.PersonId == personId).FirstOrDefault();

            if (personToRemove != null)
            {
                dbContext.People.Remove(personToRemove);
                dbContext.SaveChanges();
            }

            return(Ok());
        }
예제 #4
0
        public ActionResult EditPerson([FromBody] Person req)
        {
            int personId = req.PersonId;

            AccelaDbContext dbContext = new AccelaDbContext();

            Person personToUpdate = dbContext.People.Where(x => x.PersonId == personId).FirstOrDefault();

            if (personToUpdate != null)
            {
                personToUpdate.Title       = req.Title;
                personToUpdate.FirstName   = req.FirstName;
                personToUpdate.LastName    = req.LastName;
                personToUpdate.Email       = req.Email;
                personToUpdate.Telephone   = req.Telephone;
                personToUpdate.DateOfBirth = req.DateOfBirth;

                dbContext.SaveChanges();
            }

            return(Ok());
        }