Пример #1
0
        public void Run()
        {
            bool inMenu = true;
            int  command;

            while (inMenu)
            {
                PrintSpaces();
                Console.Write(GetMenu());
                try
                {
                    command = Int32.Parse(Console.ReadLine());
                }
                catch (Exception e) { continue; }


                switch (command)
                {
                case 1:
                    Student s = ReadStudent();
                    if (s == null)
                    {
                        Console.Write("Incorrect data.");
                    }
                    else
                    {
                        Console.Write(service.AddStudent(s) + "\n");
                    }
                    break;

                case 2:
                    s = ReadStudent();
                    if (s == null)
                    {
                        Console.Write("Incorrect data.");
                    }
                    else
                    {
                        Console.Write(service.UpdateStudent(s) + "\n");
                    }
                    break;

                case 3:
                    Console.Write("Id: ");
                    string id = Console.ReadLine();
                    if (id == null)
                    {
                        Console.Write("Incorrect data.");
                    }
                    else
                    {
                        Console.Write(service.DeleteStudent(id) + "\n");
                    }
                    break;

                case 0:
                    inMenu = false;
                    break;
                }
            }
        }
 public ActionResult DeleteConfirmed(int id)
 {
     teacherService.DeleteStudent(id);
     TempData["message"] = "Deleted Succssesfully";
     return(RedirectToAction("Index"));
 }