public ActionResult EditMore(OnlineStudent os) { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Login")); } string Uid = Session["UserID"].ToString(); int uuid = Convert.ToInt32(Uid); OnlineStudent update = db.OnlineStudents.Where(x => x.UserId == uuid).FirstOrDefault(); if (Session["Username"] == null) { return(RedirectToAction("Login", "Login")); } string name = Session["Username"].ToString(); User pp = db.Users.Where(p => p.UserName == name).FirstOrDefault(); update.UserId = pp.UserId; update.StudentName = pp.UserName; update.MobileNo = os.MobileNo; update.StdInstitute = os.StdInstitute; update.Address = os.Address; db.SaveChanges(); return(RedirectToAction("StudentEdit")); }
public IHttpActionResult Post(OnlineStudent onlineStudent) { stdRepo.Insert(onlineStudent); string url = Url.Link("GetStudentById", new { id = onlineStudent.StudentId }); return(Created(url, onlineStudent)); }
static void Main() { Trainer nikbank = new JuniorTrainer("Nikolay", "Bankin", 20); Trainer vGeorg = new SeniorTrainer("Vlado", "Geogiev", 25); Trainer nakov = new SeniorTrainer("Svetlin", "Nakov", 32); Trainer aRus = new JuniorTrainer("Atanas", "Rusenov", 18); Student toi = new GraduateStudent("Zavyrshil", "Student", 21, "80002341", (float)5.46); Student blagoi = new GraduateStudent("Blago", "Peshev", 25, "80002145", (float)5.22); Student misho = new GraduateStudent("Misho", "Mishev", 12, "80004587", (float)5.96); Student pesho = new DropoutStudent("Pesho", "Peshev", 23, "40001234", (float)2.33, "low result"); Student katya = new DropoutStudent("Katya", "Ivanova", 72, "40005678", (float)4.33, "family reasons"); CurrentStudent valyo = new OnlineStudent("Valentin", "Petrov", 11, "50006541", (float)3.45, "Java Basics"); CurrentStudent geca = new OnlineStudent("Georgi", "Petrov", 34, "50002389", (float)4.45, "JavaScript Basics"); CurrentStudent batkata = new OnsiteStudent("Botyo", "Botev", 36, "50009841", (float)5.85, "C# Basics", 8); List <Person> persons = new List <Person>() { nikbank, vGeorg, nakov, aRus, toi, blagoi, misho, pesho, katya, valyo, geca, batkata }; persons.Where(p => p is CurrentStudent).OrderBy(p => ((Student)p).AverageGrade).ToList().ForEach(p => Console.WriteLine(p.ToString())); }
public ActionResult ConfirmDelete(int id) { OnlineStudent s = userRepo.OnlineStudents.Where(x => x.StudentId == id).FirstOrDefault(); userRepo.OnlineStudents.Remove(s); userRepo.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Details(int id) { OnlineStudent s = userRepo.OnlineStudents.Where(x => x.StudentId == id).FirstOrDefault(); s.StudentId = id; OnlineStudent[] students = userRepo.OnlineStudents.ToArray(); ViewData["student"] = students; return(View(s)); }
public IHttpActionResult Get(int id) { OnlineStudent onlineStudent = stdRepo.GetById(id); if (onlineStudent == null) { return(StatusCode(HttpStatusCode.NoContent)); } return(Ok(onlineStudent)); }
public static void Main() { JuniorTrainer juniorTrainer1 = new JuniorTrainer("Pesho", "Peshov", 24); JuniorTrainer juniorTrainer2 = new JuniorTrainer("GonlineStudentho", "GonlineStudentov", 27); JuniorTrainer juniorTrainer3 = new JuniorTrainer("Vladko", "Vladov", 19); SeniorTrainer seniorTrainer1 = new SeniorTrainer("Petko", "Petkov", 33); SeniorTrainer seniorTrainer2 = new SeniorTrainer("Stefan", "Stefanov", 38); SeniorTrainer seniorTrainer3 = new SeniorTrainer("Martin", "Martinov", 29); GraduateStudent graduateStudent1 = new GraduateStudent("Ivan", "Novakov", 35, 30020925, 4.45M); GraduateStudent graduateStudent2 = new GraduateStudent("RadonlineStudentlav", "Simeonov", 28, 30058925, 5.80M); GraduateStudent graduateStudent3 = new GraduateStudent("Teodor", "Stoychev", 33, 300521345, 3.00M); DropoutStudent dropoutStudent1 = new DropoutStudent("Nakovalnq", "Nakovalnev", 35, 30020925, 4.45M, "..."); DropoutStudent dropoutStudent2 = new DropoutStudent("Mmmm", "IdropOut", 28, 30058925, 5.80M, "I dropoutStudentn't care zzzZZZzzz..."); DropoutStudent dropoutStudent3 = new DropoutStudent("Arnold", "Ill' be back", 33, 300521345, 3.00M, "Terminated!!!"); OnlineStudent onlineStudent1 = new OnlineStudent("Emil", "Stefanov", 48, 40018512, 3.33M, "OOP"); OnlineStudent onlineStudent2 = new OnlineStudent("Martin", "Todorov", 22, 40065415, 5.45M, "OOP"); OnlineStudent onlineStudent3 = new OnlineStudent("Valeri", "Zahariev", 18, 40018525, 4.89M, "OOP"); OnsiteStudent onsiteStudent1 = new OnsiteStudent("Natalya", "Alexandrova", 31, 40089564, 4.00M, "OOP", 5); OnsiteStudent onsiteStudent2 = new OnsiteStudent("Adriyana", "Alexandrova", 25, 40012188, 5.25M, "OOP", 5); OnsiteStudent onsiteStudent3 = new OnsiteStudent("Peter", "Simeonov", 30, 40035698, 3.80M, "OOP", 3); juniorTrainer1.CreateCourse("Drink brave!"); seniorTrainer1.CreateCourse("I'm alive!"); seniorTrainer2.DeleteCourse("Drink brave!"); dropoutStudent3.Reapply(); List <Person> softUniPersons = new List <Person> { juniorTrainer1, juniorTrainer2, juniorTrainer3, seniorTrainer1, seniorTrainer2, seniorTrainer3, graduateStudent1, graduateStudent2, graduateStudent3, dropoutStudent1, dropoutStudent2, dropoutStudent3, onsiteStudent1, onsiteStudent2, onsiteStudent3, onlineStudent1, onlineStudent2, onlineStudent3 }; SULS testSoftUni = new SULS(softUniPersons); testSoftUni.ExtractCurrentStudents(); }
public ActionResult EditMore() { if (Session["UserID"] == null) { return(RedirectToAction("Login", "Login")); } string Uid = Session["UserID"].ToString(); int uuid = Convert.ToInt32(Uid); OnlineStudent update = db.OnlineStudents.Where(x => x.UserId == uuid).FirstOrDefault(); return(View(update)); }
public ActionResult UploadPro(HttpPostedFileBase file, int id) { string FileName = Path.GetFileName(file.FileName); string FilePath = Path.Combine(Server.MapPath("~/Uploaded/ProImage/"), FileName); OnlineStudent profileToUpdate = db.OnlineStudents.Where(x => x.UserId == id).FirstOrDefault(); profileToUpdate.ImageName = FileName; profileToUpdate.ImagePath = FilePath; file.SaveAs(FilePath); db.SaveChanges(); return(RedirectToAction("StudentEdit")); }
static void Main() { var nikbank = new JuniorTrainer("Nikolay", "Bankin", "8080808080"); var vKaranf = new SeniorTrainer("Vlado", "Karnfilov", "7070807070"); Console.WriteLine(nikbank); Console.WriteLine(vKaranf); nikbank.CreateCourse("OOP"); vKaranf.CreateCourse("C# Part:2"); vKaranf.DeleteCourse("C# Part:2"); Console.WriteLine(new string('*', Console.WindowWidth)); var student1 = new GradulateStudent("Gosho", "Loshov", "1234567890", 34, 5.60); var student2 = new GradulateStudent("Pesho", "Poshov", "1234567890", 12, 3.60); var student3 = new GradulateStudent("Mari", "Markova", "1234567890", 1, 4.20); var student13 = new DropoutStudent("Niki", "Nikov", "1234567890", 4, 2.00, "low result"); var student14 = new DropoutStudent("Mari", "Markova", "1234567890", 1, 4.20, "family reason"); var student11 = new OnlineStudent("Mitko", "Mitkov", "1234567890", 2, 2.60); var student21 = new OnsiteStudent("Goro", "Gororv", "1234567890", 2, 5.66); student21.Visits = 23; var persons = new HashSet<Person>() { nikbank, vKaranf, student1, student1, student11, student13, student14, student2, student3, student21 }; student11.CurrentCourses.Add("C# Part 1"); var selectedStudents = from person in persons where person is CurrentStudent orderby ((Student)person).AverageGrade descending select person; foreach (var student in selectedStudents) { Console.WriteLine(student); } }
public ActionResult Edit(OnlineStudent t, int id) { OnlineStudent StudentToUpdate = userRepo.OnlineStudents.Where(x => x.StudentId == id).FirstOrDefault(); StudentToUpdate.StudentId = id; StudentToUpdate.StudentName = t.StudentName; //StudentToUpdate.Email = t.Email; StudentToUpdate.MobileNo = t.MobileNo; StudentToUpdate.Address = t.Address; StudentToUpdate.StdInstitute = t.StdInstitute; //StudentToUpdate.JoinDate = t.JoinDate; //StudentToUpdate.EnrolledCourse = t.EnrolledCourse; // StudentToUpdate.Status = t.Status; //StudentToUpdate.ImageFile = t.ImageFile; userRepo.SaveChanges(); return(RedirectToAction("Index")); }
static void Main() { List<object> list = new List<object>(); Person stamat = new Person("Stamat", "Stamtov", 18); Trainer vladi = new Trainer("Vladi", "Vargala", 24); SeniorTrainer nakov = new SeniorTrainer("Svetin", "Nakov", 22); JuniorTrainer niki = new JuniorTrainer("Nikolay", "Bankin", 18); niki.CreateCourse("Tvardost na betona"); nakov.DeleteCourse("Tvardost na betona"); Student mimi = new Student("Mariya", "Ilieva", 25, 1345, 4.60); DropoutStudent vasko = new DropoutStudent("Vasko", "Keca", 17, 300, 5, "Music"); vasko.Reapply(); GraduateStudent nobody = new GraduateStudent("Misho", "Birata", 40, 20, 3.40); OnlineStudent uncleTony = new OnlineStudent("Uncle", "Antony", 25, 7, 5, "OOP"); CurrentStudent me = new CurrentStudent("Gosho", "Lyaskov", 28, 1, 5.4, "OOP"); CurrentStudent you = new CurrentStudent("Pesho", "Peshev", 28, 2, 5.1, "OOP"); CurrentStudent somebody = new CurrentStudent("Uncnown", "Person", 14, 190, 6, "OOP"); AddtoList(list, stamat, vladi, nakov, niki, mimi, vasko, nobody, uncleTony, me, you, somebody); list.Where(x => x is CurrentStudent).OrderByDescending(x => ((Student)x).StudentAverageGrade).ToList().ForEach(x => Console.WriteLine(x.ToString())); }
public ActionResult CreateMore(OnlineStudent oo) { OnlineStudent update = new OnlineStudent(); if (Session["Username"] == null) { return(RedirectToAction("Login", "Login")); } string name = Session["Username"].ToString(); User pp = db.Users.Where(p => p.UserName == name).FirstOrDefault(); update.UserId = pp.UserId; update.StudentName = pp.UserName; update.MobileNo = oo.MobileNo; update.StdInstitute = oo.StdInstitute; update.Address = oo.Address; db.OnlineStudents.Add(update); db.SaveChanges(); return(RedirectToAction("StudentEdit")); }
static void Main() { var nasko = new Trainer("Atanas", "Rusenov", 21); var fill = new JuniorTrainer("Filip", "Kolev", 28); var nakov = new SeniorTrainer("Svetlin", "Nakov", 60); var mark = new GraduateStudent("Марк", "Зукърбъргов", 38, 120511, 6.00); var mitio = new DropoutStudent("Митьо", "Крика", 40, 343535, 2.30, "Много големи ръки"); var djordjano = new CurrentStudent("Djordjano", "Djordjankata", 25, 0888155, "Introducing to singing"); var baiVulcho = new OnlineStudent("Бай", "Вълчо", 73, 4444, 5.60, "OOP"); var lelqVanche = new OnsiteStudent("Леля", "Ванче", 57, 12034, 4.89, "Аdvanced C#", 20); nakov.DeleteCourse("PHP"); fill.CreateCourse("Advanced C#"); nasko.CreateCourse("Kopane"); nakov.DeleteCourse("Kopane"); // Nasko, what are you doing?!? Console.WriteLine(); var persons = new List <Person>() { nasko, fill, nakov, mark, mitio, djordjano, baiVulcho, lelqVanche }; var currentStudents = persons.Where(student => student is CurrentStudent) .OrderBy(student => ((Student)student).AverageGrade) .Select(student => student); foreach (var currentStudent in currentStudents) { Console.WriteLine(currentStudent); } }
static void Main() { var nasko = new Trainer("Atanas", "Rusenov", 21); var fill = new JuniorTrainer("Filip", "Kolev", 28); var nakov = new SeniorTrainer("Svetlin", "Nakov", 60); var mark = new GraduateStudent("Марк", "Зукърбъргов", 38, 120511, 6.00); var mitio = new DropoutStudent("Митьо", "Крика", 40, 343535, 2.30, "Много големи ръки"); var djordjano = new CurrentStudent("Djordjano", "Djordjankata", 25, 0888155,"Introducing to singing"); var baiVulcho = new OnlineStudent("Бай", "Вълчо", 73, 4444, 5.60,"OOP"); var lelqVanche = new OnsiteStudent("Леля", "Ванче", 57, 12034, 4.89, "Аdvanced C#", 20); nakov.DeleteCourse("PHP"); fill.CreateCourse("Advanced C#"); nasko.CreateCourse("Kopane"); nakov.DeleteCourse("Kopane"); // Nasko, what are you doing?!? Console.WriteLine(); var persons = new List<Person>() { nasko, fill, nakov, mark, mitio, djordjano, baiVulcho, lelqVanche }; var currentStudents = persons.Where(student => student is CurrentStudent) .OrderBy(student => ((Student)student).AverageGrade) .Select(student => student); foreach (var currentStudent in currentStudents) { Console.WriteLine(currentStudent); } }
static void Main() { List <Person> softUniPeople = new List <Person>(); string checker = null; uint studentNumber = 0u; float averageGrade = 0f; string currentCourse = null; uint numberOfVisits = 0u; string dropoutReason = null; do { Person temp; Console.WriteLine("Please choose a type of object:"); Console.WriteLine("1 - Person"); Console.WriteLine("2 - Trainer"); Console.WriteLine("3 - Junior Trainer"); Console.WriteLine("4 - Senior Trainer"); Console.WriteLine("5 - Student"); Console.WriteLine("6 - GraduateStudent"); Console.WriteLine("7 - CurrentStudent"); Console.WriteLine("8 - Online Student"); Console.WriteLine("9 - Onsite Student"); Console.WriteLine("10 - Dropout Student"); byte typeOfObject = byte.Parse(Console.ReadLine()); Console.WriteLine("Please enter a first name:"); string firstName = Console.ReadLine(); Console.WriteLine("Please enter a last name:"); string lastName = Console.ReadLine(); Console.WriteLine("Please enter an age:"); int age = int.Parse(Console.ReadLine()); if (typeOfObject >= 5) { Console.WriteLine("Please enter a student number:"); studentNumber = uint.Parse(Console.ReadLine()); Console.WriteLine("Please enter an average grade:"); averageGrade = float.Parse(Console.ReadLine()); if (typeOfObject >= 7 && typeOfObject <= 9) { Console.WriteLine("Please enter student current course:"); currentCourse = Console.ReadLine(); if (typeOfObject == 9) { Console.WriteLine("Please enter a numebr of visits:"); numberOfVisits = uint.Parse(Console.ReadLine()); } } else if (typeOfObject == 10) { Console.WriteLine("Please enter dropout reason"); dropoutReason = Console.ReadLine(); } } switch (typeOfObject) { case (1): temp = new Person(firstName, lastName, age); break; case (2): temp = new Trainer(firstName, lastName, age); break; case (3): temp = new JuniorTrainer(firstName, lastName, age); break; case (4): temp = new SeniorTrainer(firstName, lastName, age); break; case (5): temp = new Student(firstName, lastName, age, studentNumber, averageGrade); break; case (6): temp = new GraduateStudent(firstName, lastName, age, studentNumber, averageGrade); break; case (7): temp = new CurrentStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse); break; case (8): temp = new OnlineStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse); break; case (9): temp = new OnsiteStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse, numberOfVisits); break; case (10): temp = new DropoutStudent(firstName, lastName, age, studentNumber, averageGrade, dropoutReason); break; default: Console.WriteLine("Invalid object type"); continue; } Console.WriteLine("Would you like to print the current object? Y\\N"); checker = Console.ReadLine(); if (checker == "Y" || checker == "y") { Console.WriteLine(temp.ToString()); } if (typeOfObject >= 2 && typeOfObject <= 4) { Console.WriteLine("Would you like to add a course? Y\\N"); checker = Console.ReadLine(); if (checker == "Y" || checker == "y") { Console.WriteLine("Please enter a course name:"); string course = Console.ReadLine(); Trainer tempTrainer = (Trainer)temp; tempTrainer.CreateCourse(course); } if (typeOfObject == 4) { Console.WriteLine("Would you like to delete a course? Y\\N"); checker = Console.ReadLine(); if (checker == "Y" || checker == "y") { Console.WriteLine("Please enter a course name:"); string course = Console.ReadLine(); SeniorTrainer tempTrainer = (SeniorTrainer)temp; tempTrainer.DeleteCourse(course); } } } if (typeOfObject == 10) { Console.WriteLine("Would you like to reapply? Y\\N"); checker = Console.ReadLine(); if (checker == "Y" || checker == "y") { DropoutStudent tempStudent = (DropoutStudent)temp; tempStudent.Reapply(); } } softUniPeople.Add(temp); Console.WriteLine("Would you like to add another object? Y\\N"); checker = Console.ReadLine(); } while (checker != "N" && checker != "n"); softUniPeople.Where(p => p is CurrentStudent).OrderBy(p => ((CurrentStudent)p).AverageGrade).ToList().ForEach(p => Console.WriteLine(p.ToString())); }
public IHttpActionResult Put([FromBody] OnlineStudent onli) { stdRepo.Edit(onli); return(Ok(onli)); }
public static void Main() { SeniorTrainer nakov = new SeniorTrainer( "Svetlin", "Nakov", 22); // forever young :D Trainer vGeorgiev = new JuniorTrainer( "Vladimir", "Georgiev", 20); Student graduated = new GraduateStudent( "Ivan", "Ivanov", 25, 2213435, (float)5.60); Student dropoutedOne = new DropoutStudent( "Vasil", "Vasilev", 21, 11643, (float)2.41, "unpaid semester"); DropoutStudent dropoutedTwo = new DropoutStudent( "Nikolay", "Nikolov", 26, 4566789, (float)2.25, "bad results"); Student currentOne = new OnsiteStudent("Petyr", "Petrov", 19, 411313, (float)4.67, "OOP", 2); Student currentTwo = new OnlineStudent( "Stoyan", "Stoyanov", 32, 2323439, (float)5.19, "Java Basics"); List <Person> persons = new List <Person>() { nakov, vGeorgiev, graduated, dropoutedOne, dropoutedTwo, currentOne, currentTwo }; Console.WriteLine("Current students:"); // sort and call ToString method persons.Where(p => p is CurrentStudent).OrderBy(p => ((CurrentStudent)p).AverageGrade).ToList().ForEach(p => Console.WriteLine(p.ToString())); // create/delete courses Console.WriteLine("Created/deleted courses:"); Console.WriteLine(vGeorgiev.CreateCourse("OPP")); Console.WriteLine(nakov.DeleteCourse("Java Basics")); Console.WriteLine(); // reaply students Console.WriteLine("Reaply students:"); Console.WriteLine(dropoutedTwo.Reaplly()); }
public ActionResult Create(OnlineStudent s) { userRepo.OnlineStudents.Add(s); userRepo.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { OnlineStudent s = userRepo.OnlineStudents.Where(x => x.StudentId == id).FirstOrDefault(); return(View(s)); }
static void Main() { Random randGenerator = new Random(); Console.Write("Input the number of people. "); int peopleCount = int.Parse(Console.ReadLine()); Console.WriteLine(); Person[] people = new Person[peopleCount]; List<CurrentStudent> students = new List<CurrentStudent>(); Console.WriteLine(new string('-', 40)); Console.WriteLine("People"); Console.WriteLine(new string('-', 40)); int studentID = 0; for (int index = 0; index < peopleCount; index++) { string firstName = ((firstNames)randGenerator.Next(9)).ToString(); string lastName = ((lastNames)randGenerator.Next(9)).ToString(); string type = ((types)randGenerator.Next(6)).ToString(); int age = randGenerator.Next(80); double averageGrade = (randGenerator.NextDouble() * 4) + 2; string course = ((courses)randGenerator.Next(5)).ToString(); switch (type) { case "JuniorTrainer": people[index] = new JuniorTrainer(firstName, lastName, age); break; case "SeniorTrainer": people[index] = new SeniorTrainer(firstName, lastName, age); break; case "GraduateStudent": people[index] = new GraduateStudent(firstName, lastName, age, studentID, averageGrade); studentID++; break; case "DropoutStudent": people[index] = new DropoutStudent(firstName, lastName, age, studentID, averageGrade, "Being lazy..."); studentID++; break; case "OnlineStudent": people[index] = new OnlineStudent(firstName, lastName, age, studentID, averageGrade, course); students.Add(new OnlineStudent(firstName, lastName, age, studentID, averageGrade, course)); studentID++; break; default: int numberOfVisits = randGenerator.Next(125); people[index] = new OnsiteStudent(firstName, lastName, age, studentID, averageGrade, course, numberOfVisits); students.Add(new OnsiteStudent(firstName, lastName, age, studentID, averageGrade, course, numberOfVisits)); studentID++; break; } Console.WriteLine(people[index].ToString()); Console.WriteLine(); } Console.WriteLine(new string('-', 40)); Console.WriteLine("Current Students Ranking"); Console.WriteLine(new string('-', 40)); students = students.OrderBy(s => s.AverageGrade).ToList(); foreach (CurrentStudent student in students) { Console.WriteLine(student.ToString()); Console.WriteLine(); } }