public StudentCourse UpdateStudentCourse(StudentCourse studentCourse, ServerInformation serverInformation) { var studentCourseUpdate = GetStudentCourseByStudentIDCourseID(studentCourse.StudentId, studentCourse.CourseId); if (studentCourseUpdate != null) { if (studentCourseUpdate.Validate == null || (studentCourse.Validate.Value.Day != DateTime.Now.Day)) { //daca nu a validat deloc sau nu a validat azi studentCourse.Validate = DateTime.Now; switch (serverInformation.classRoom.TypeOfStudy) { case "Course": studentCourse.AttendanceStudentCourse++; break; case "Seminar": studentCourse.AttendanceStudentSeminar++; break; case "Lab": studentCourse.AttendanceStudentLab++; break; } schoolDBFirstContext.StudentCourse.Update(studentCourseUpdate); schoolDBFirstContext.SaveChanges(); return(studentCourseUpdate); } return(studentCourseUpdate); } return(null); }
public Course Save(Course course) { course.StudentCourse = null; schoolDBFirstContext.Course.Add(course); schoolDBFirstContext.SaveChanges(); return(course); }
public void RemoveEducation(int teacherId) { var lst = context.TeachersEducations.Where(te => te.TeacherId == teacherId); context.TeachersEducations.RemoveRange(lst); context.SaveChanges(); }
public void DeleteStudent(int id) { var data = schoolDBContext.Students.SingleOrDefault(a => a.Id == id); schoolDBContext.Remove(data); schoolDBContext.SaveChanges(); }
public Student SaveStudent(Student student) { // student.StudentCourses = null; schoolDBFirstContext.Student.Add(student); schoolDBFirstContext.SaveChanges(); return(student); }
public ClassRoom Save(ClassRoom classRoom) { classRoom.ClassRoomCourse = null; schoolDBFirstContext.ClassRoom.Add(classRoom); schoolDBFirstContext.SaveChanges(); return(classRoom); }
public static Operation Create(StudentAssistant model) { try { model.Status = Models.Enums.RecordStatus.Active; db.StudentAssistants.Add(model); db.SaveChanges(); return(new Operation() { Code = "Ok", Message = new List <string>() { "Student Assistant is created successfully." } }); } catch (Exception e) { return(new Operation() { Code = "Fail", Message = new List <string>() { e.Message } }); } }
public IHttpActionResult PutStudent(int id, Student student) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != student.StudentId) { return(BadRequest()); } db.Entry(student).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public static Operation Create(FAQEntry model) { try { db.FAQEntries.Add(model); db.SaveChanges(); return(new Operation() { Code = "Ok", Message = new List <string>() { "FAQ is created successfully." } }); } catch (Exception e) { return(new Operation() { Code = "Fail", Message = new List <string>() { e.Message } }); } }
public LoginResponse CreateStudentLogin(StudentLogin studentLoginObj) { _schoolDBContext.StudentLogins.Add(studentLoginObj); _schoolDBContext.SaveChanges(); return(new LoginResponse { Status = "Success", Message = "Account sucessfully generated!" }); }
public ActionResult Create([Bind(Include = "Id,Title,Stream,Type,StartDate,EndDate")] Course course) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ActionResult Create([Bind(Include = "id,Name,Gender,IsChecked")] Person person) { if (ModelState.IsValid) { db.Persons.Add(person); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(person)); }
public IActionResult Post([FromBody] Teacher teacher) { if (teacher == null) { return(BadRequest()); } db.Teachers.Add(teacher); db.SaveChanges(); return(Ok(teacher)); }
public IActionResult Post([FromBody] Student student) { if (student == null) { return(BadRequest()); } db.Students.Add(student); db.SaveChanges(); return(Ok(student)); }
public ActionResult Create([Bind(Include = "Id,Description,MinSat")] Major major) { if (ModelState.IsValid) { db.Majors.Add(major); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(major)); }
public ActionResult Create([Bind(Include = "CourseId,CourseName")] Course course) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public static Operation Login(GuestLoginViewModel model) { try { Guest guest = db.Guests.FirstOrDefault(g => g.PersonName.ToLower() == model.PersonName.ToLower() && g.Gender == model.Gender); Guid?guestId = Guid.NewGuid(); if (guest == null) { db.Guests.Add(new Guest() { Id = guestId, Address = model.Address, Age = model.Age, Gender = model.Gender, PersonName = model.PersonName }); } else { guestId = guest.Id; } db.GuestLogs.Add(new GuestLog() { Id = Guid.NewGuid(), GuestId = guestId, Temperature = model.Temperature, VisitAt = DateTime.Now }); db.SaveChanges(); return(new Operation() { Code = "Ok", Message = new List <string>() { "Guest is created successfully." } }); } catch (Exception e) { return(new Operation() { Code = "Fail", Message = new List <string>() { e.Message } }); } }
public ActionResult Create([Bind(Include = "FirstName,LastName")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Create([Bind(Include = "ID,School_Name,Address,Classes,Staff")] School school) { if (ModelState.IsValid) { db.School.Add(school); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(school)); }
public ActionResult Create([Bind(Include = "TeacherID,Firstname,Lastname")] Teacher teacher) { if (ModelState.IsValid) { db.Teachers.Add(teacher); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(teacher)); }
public ActionResult Create([Bind(Include = "Id,Title,Description,SubDate,OralMark,TotalMark,Course")] Assignment assignment) { if (ModelState.IsValid) { db.Assignments.Add(assignment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(assignment)); }
public ActionResult Create([Bind(Include = "Id,FirstName,LastName,BirthDate,TuitionFees,Course,ImageURL")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Subject,Course,ImageURL")] Trainer trainer) { if (ModelState.IsValid) { db.Trainers.Add(trainer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(trainer)); }
public ActionResult Create([Bind(Include = "Id,Firstname,Lastname,MajorId,SAT")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MajorId = new SelectList(db.Majors, "Id", "Description", student.MajorId); return(View(student)); }
public ActionResult Create([Bind(Include = "Id,Description,MajorId")] Class @class) { if (ModelState.IsValid) { db.Classes.Add(@class); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MajorId = new SelectList(db.Majors, "Id", "Description", @class.MajorId); return(View(@class)); }
public ActionResult Create([Bind(Include = "Id,StudentId,ClassId,Grade")] Enrolled enrolled) { if (ModelState.IsValid) { db.Enrolleds.Add(enrolled); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClassId = new SelectList(db.Classes, "Id", "Description", enrolled.ClassId); ViewBag.StudentId = new SelectList(db.Students, "Id", "Firstname", enrolled.StudentId); return(View(enrolled)); }
public static void DeletingData() { SchoolDBContext context = new SchoolDBContext(); try { var std = context.Student.First <Estudiantes>(); context.Student.Remove(std); bool deleted = context.SaveChanges() > 0; if (deleted) { Console.WriteLine("Ha Sido Eliminado"); } else { Console.WriteLine("No se Pudo Eliminar Error"); } } catch (Exception) { throw; } finally { context.Dispose(); } }
public static void GuardarCurso() { SchoolDBContext context = new SchoolDBContext(); try { var auxCourse = new Cursos() { CursoId = 0, NombreCurso = "Sociales" }; context.Courses.Add(auxCourse); bool save = context.SaveChanges() > 0; if (save) { Console.WriteLine("Guardado !!"); } else { Console.WriteLine("No se pudo Guardar"); } } catch (Exception) { throw; } finally { context.Dispose(); } }
public void RegisterStudent(string fname, string lname, string username, string passcode, DateTime dob, string homePhone, string mobile, string email, string addr, string postcode, string city, int credits) { using var db = new SchoolDBContext(); var mail = (fname.ElementAt(0) + lname) + emailSignature; db.Add(new Student { FirstName = fname, LastName = lname, Username = username, Passcode = passcode, Dob = dob, HomePhone = homePhone, MobilePhone = mobile, Email = mail, Addr = addr, Postcode = postcode, City = city }); db.SaveChanges(); }
public ActionResult <IEnumerable <string> > Get() { SchoolDBContext db = new SchoolDBContext(); var dbx = new List <string>() { "value1", "value2" }; if (db.Artists.Count() > 21) { foreach (var name in db.Artists) { dbx.Add(name.ArtistName); } } else { db.Artists.Add(new Artists() { ArtistName = "Hamlet", Age = 100 }); } db.SaveChanges(); return(dbx.ToArray()); }