Exemplo n.º 1
0
        /// <summary>
        /// Deletes the given Patient and their Person from the db
        /// </summary>
        /// <param name="patient">Patient to delete</param>
        /// <returns>Whether or not the Patient was deleted</returns>
        public bool DeletePatient(Patient patient)
        {
            Person person = PersonDAL.GetPersonByPatientID(patient);

            using (TransactionScope scope = new TransactionScope())
            {
                PatientDAL.DeletePatient(patient);
                PersonDAL.DeletePerson(person);
                scope.Complete();
            }
            return(true);
        }
Exemplo n.º 2
0
        public IActionResult DeletePerson()
        {
            InitView();

            var         id     = HttpContext.Session.GetString(personIdKey);
            PersonModel person = null;

            try
            {
                var personDal = new PersonDAL(_configuration);
                person = personDal.GetPerson(id);
                personDal.DeletePerson(id);
                ViewBag.ErrorMessage = string.Empty;
            }
            catch (Exception)
            {
                ViewBag.ErrorMessage = "Error Deleting Person from Database";
            }

            return(View(person));
        }
Exemplo n.º 3
0
        public void PersonDALMenu()
        {
            while (true)
            {
                System.Console.WriteLine("Welcome in Role");
                System.Console.WriteLine("c - Create");
                System.Console.WriteLine("r - read one");
                System.Console.WriteLine("rall - read all");
                System.Console.WriteLine("u - update");
                System.Console.WriteLine("d - delete");
                System.Console.WriteLine("else - exit");

                string a = System.Console.ReadLine();



                switch (a)
                {
                case "c":
                    System.Console.WriteLine("Input Person :");
                    person = dal.CreatePerson(new PersonDTO {
                        FirstName = System.Console.ReadLine()
                    });
                    System.Console.WriteLine("You add the: Id - " + person.PersonId + " Name - " + person.FirstName);
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "r":
                    System.Console.Write("Choose Id: ");
                    person = dal.GetPersonById(System.Convert.ToInt32(System.Console.ReadLine()));
                    System.Console.WriteLine("You read the: Id - " + person.PersonId + " Name - " + person.FirstName);
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "rall":
                    List <PersonDTO> categories = dal.GetAllPerson();
                    for (int i = 0; i < person.Count; i++)
                    {
                        System.Console.WriteLine("Id - " + person[i].RoleId + " Name - " + person[i].FirstName);
                    }
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "u":
                    System.Console.WriteLine("Update Name:");
                    person = dal.UpdatePerson(new PersonDTO {
                        FirstName = System.Console.ReadLine()
                    });
                    System.Console.WriteLine("You add the: Id - " + person.PersonId + " Name - " + person.FirstName);
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "d":
                    System.Console.WriteLine("Choose Id:");
                    dal.DeletePerson(System.Convert.ToInt32(System.Console.ReadLine()));
                    System.Console.WriteLine("Delete successful");
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "else":
                    break;
                }
            }
        }