public async Task <IActionResult> Edit(int id, [Bind("Id,DepartmentId,Name,Gender,Nation,HireDate,PhoneNumber,Email,Academic,OfficeLocation,Password")] Models.Instructor instructor) { if (id != instructor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(instructor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InstructorExists(instructor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Profile")); } return(RedirectToAction("Profile")); }
/// <summary> /// Chain Cybirst.Instructor to DAL.Models.Instructor /// </summary> /// <param name="item"></param> /// <returns></returns> public DAL.Models.Instructor Chain(Cybirst.Instructor item) { DAL.Models.Instructor inst = new Models.Instructor(); inst.ID = item.ID; inst.UID = item.UID; inst.FirstName = item.FirstName; inst.LastName = item.LastName; inst.Intro = item.Intro; inst.ShortIntro = item.ShortIntro; inst.GooglePlus = item.GooglePlus; inst.Twitter = item.Twitter; inst.Facebook = item.Facebook; inst.GitHub = item.GitHub; inst.Blog = item.Blog; inst.Email = item.Email; inst.Password = item.Password; inst.Phone = item.Phone; inst.Address = item.Address; inst.SmAvatar = item.SmAvatar; inst.MdAvatar = item.MdAvatar; inst.LgAvatar = item.LgAvatar; inst.TotalCourses = item.TotalCourses; // inst.Teachings List <string> teachs = new List <string>(); List <Course> lstCourses = item.Courses.ToList <Course>(); inst.Courses = this.Convert(item.Courses.ToList()); foreach (var course in lstCourses) { Technology tech = course.Technology; teachs.Add(tech.Name.Trim()); } inst.Teachings = teachs.Distinct().ToList(); return(inst); }
private void SetAccount() { int id = Program.AccoutnID; //int id = HttpContext.Session.Get<int>("Account"); _instructor = _context.Instructor.SingleOrDefault(i => i.Id == id); adminDeptID = -1; htEClassID = -1; }
public ActionResult Instructor(int id) { ViewBag.Id = id; Models.Instructor daytimeInstructor = new Models.Instructor { Id = 1, FirstName = "Erik", LastName = "Gross" }; return(View(daytimeInstructor)); }
// GET: Instructor/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Models.Instructor instructor = db.Instructors.Find(id); if (instructor == null) { return(HttpNotFound()); } return(View(instructor)); }
protected void btnSave_Click(object sender, EventArgs e) { var instructorID = Request.QueryString["ID"]; if (Page.IsValid && instructorID == null) { Contoso.Models.Instructor instructor = new Models.Instructor(); instructor.ID = Convert.ToInt32(ddlID.SelectedValue); instructor.HireDate = Convert.ToDateTime(txtHireDate.Text); InstructorService instructorService = new InstructorService(); instructorService.AddInstructor(instructor); } if (Page.IsValid && instructorID != null) { Contoso.Models.Instructor instructor = new Models.Instructor(); instructor.ID = Convert.ToInt32(ddlID.SelectedValue); instructor.HireDate = Convert.ToDateTime(txtHireDate.Text); InstructorService instructorService = new InstructorService(); instructorService.UpdateInstructor(instructor); } }
//Create DB if none exists and populate test data public static void initializeDB() { SQLiteConnection con = new SQLiteConnection(dbPath); DateTime now = DateTime.Now; try { con.CreateTable <Models.Assessment>(); con.CreateTable <Models.Course>(); con.CreateTable <Models.Degree>(); con.CreateTable <Models.Enrollment>(); con.CreateTable <Models.Instructor>(); con.CreateTable <Models.Student>(); con.CreateTable <Models.Term>(); } catch (Exception x) { Console.WriteLine("Error creating tables: " + x.Message); } try { if (con.Table <Models.Student>().Count() == 0) { //Get start and end dates for test data DateTime start = new DateTime(now.Year, now.Month, 1); DateTime end = start.AddMonths(6).AddHours(23).AddMinutes(59).AddSeconds(59); DateTime courseStart = start.AddDays(7); DateTime courseEnd = courseStart.AddDays(14); DateTime paAssessmentStart = courseStart.AddDays(12).AddHours(15).AddMinutes(30); DateTime paAssessmentEnd = paAssessmentStart.AddDays(1); DateTime oaAssessmentStart = paAssessmentEnd.AddHours(2).AddMinutes(30); DateTime oaAssessmentEnd = oaAssessmentStart.AddHours(2); List <DateTime> dates = new List <DateTime> { start, end, courseStart, courseEnd, paAssessmentStart, paAssessmentEnd, oaAssessmentStart, oaAssessmentEnd }; List <string> sqlDates = convertDates(dates); //Insert test student Models.Student student = new Models.Student { Name = "test", Username = "******", Password = "******" }; con.Insert(student); int studentId = student.StudentId; //Insert test degree Models.Degree degree = new Models.Degree { StudentId = studentId, Name = "My Degree", Active = 1 }; con.Insert(degree); int degreeId = degree.DegreeId; //Insert test term Models.Term term = new Models.Term { DegreeId = degreeId, Name = "First Term", Start = sqlDates[0], End = sqlDates[1] }; con.Insert(term); int termId = term.TermId; //Insert test instructor Models.Instructor instructor = new Models.Instructor() { Name = "Reg Garrett", Email = "*****@*****.**", Phone = "801-623-8070" }; con.Insert(instructor); int instructorId = instructor.InstructorId; //Insert test course Models.Course course = new Models.Course() { InstructorId = instructorId, Name = "Intro to Xamarin Forms", Status = "Enrolled", Notes = "", Start = sqlDates[2], End = sqlDates[3], StartNotification = 0, EndNotification = 0 }; con.Insert(course); int courseId = course.CourseId; //Insert Assessments Models.Assessment pa = new Models.Assessment() { CourseId = courseId, Type = "Performance Assessment", Start = sqlDates[4], End = sqlDates[5], StartNotification = 0, EndNotification = 0 }; con.Insert(pa); Models.Assessment oa = new Models.Assessment() { CourseId = courseId, Type = "Objective Assessment", Start = sqlDates[6], End = sqlDates[7], StartNotification = 0, EndNotification = 0 }; con.Insert(oa); Models.Enrollment enrollment = new Models.Enrollment() { TermId = termId, CourseId = courseId }; con.Insert(enrollment); } } catch (Exception x) { Console.WriteLine("Error populating test data: " + x.Message); } finally { con.Close(); } }