public TCPServerSender(InstructorModel instructor) { m_MaxConcurrentSends = MAX_CONCURRENT_SENDS; this.RestoreConfig(); //Register for events to track current slide m_Instructor = instructor; m_CurrentSlideID = GetSlideID(instructor); // Get initial slide if any m_Instructor.Changed["CurrentDeckTraversal"].Add(new PropertyEventHandler(OnCurrentDeckTraversalChanged)); //Create the queue m_SendQueue = new TCPServerSendQueue(); //Clients currently engaged in a send operation m_SendingParticipants = new Hashtable(); //For synchronizing the closing of client sockets m_ClosingSockets = new Hashtable(); //Current map of Client Guid to Socket m_SocketMap = new Hashtable(); ///A thread to keep data flowing from the queue: Thread sendThread = new Thread(new ThreadStart(SendThread)); sendThread.Name = "TCPServer Send Thread"; sendThread.Start(); }
/// <summary> /// Create the normal beacon message /// </summary> /// <returns></returns> protected Message InstructorMakeBeaconMessage() { using (Synchronizer.Lock(this.m_Model.Participant.SyncRoot)) { using (Synchronizer.Lock(this.m_Model.Participant.Role.SyncRoot)) { Message role = RoleMessage.ForRole(this.m_Model.Participant.Role); InstructorModel instructor = ((InstructorModel)this.m_Model.Participant.Role); if (instructor.CurrentPresentation != null) { role.InsertChild(new InstructorCurrentPresentationChangedMessage(instructor.CurrentPresentation)); } if (instructor.CurrentDeckTraversal != null) { using (Synchronizer.Lock(instructor.CurrentDeckTraversal.SyncRoot)) { Message traversal = new InstructorCurrentDeckTraversalChangedMessage(instructor.CurrentDeckTraversal); Message predecessor = traversal.Predecessor; traversal.Predecessor = new SlideInformationMessage(instructor.CurrentDeckTraversal.Current.Slide); traversal.Predecessor.InsertChild(new TableOfContentsEntryMessage(instructor.CurrentDeckTraversal.Current)); traversal.Predecessor.AddOldestPredecessor(predecessor); role.InsertChild(traversal); } } return(role); } } }
public async Task <ActionResult> Create(InstructorModel instructorModel) { if (ModelState.IsValid) { RegisterViewModel newUser = new RegisterViewModel(); newUser.Email = instructorModel.email; newUser.Password = "******"; newUser.ConfirmPassword = newUser.Password; string username = makeUserName(instructorModel.fName, instructorModel.lName, 0); var user = new ApplicationUser { UserName = username, Email = newUser.Email }; var result = await UserManager.CreateAsync(user, newUser.Password); if (result.Succeeded) { Directory.CreateDirectory(Server.MapPath("~//Uploads//instructorData//" + user.Id)); instructorModel.instructor_account_Id = user.Id; addRole(user); db.instructorModel.Add(instructorModel); db.SaveChanges(); } return(RedirectToAction("Index")); } return(View(instructorModel)); }
public void MapIValidatableListModelToInstructor_WnenMultiSelectFieldNotRequired() { //arrange ObservableCollection <IValidatable> properties = serviceProvider.GetRequiredService <IFieldsCollectionBuilder>().CreateFieldsCollection ( Descriptors.InstructorFormWithPopupOfficeAssignment, typeof(InstructorModel) ).Properties; IDictionary <string, IValidatable> propertiesDictionary = properties.ToDictionary(property => property.Name); propertiesDictionary["ID"].Value = 3; propertiesDictionary["FirstName"].Value = "John"; propertiesDictionary["LastName"].Value = "Smith"; propertiesDictionary["HireDate"].Value = new DateTime(2021, 5, 20); //act InstructorModel instructorModel = serviceProvider.GetRequiredService <IEntityStateUpdater>().GetUpdatedModel ( (InstructorModel)null, new Dictionary <string, object>(), properties, Descriptors.InstructorFormWithPopupOfficeAssignment.FieldSettings ); //assert Assert.Equal(3, instructorModel.ID); Assert.Equal("John", instructorModel.FirstName); Assert.Equal("Smith", instructorModel.LastName); Assert.Equal(new DateTime(2021, 5, 20), instructorModel.HireDate); //Assert.Equal("Location1", instructorModel.OfficeAssignment.Location); Assert.Null(instructorModel.Courses); }
public InstructorModel GetInstructorByUserId(int id) { using (SZPNUWContext context = new SZPNUWContext()) { Lecturers lecturer = context.Lecturers.Include(x => x.User).FirstOrDefault(s => s.User.Id == id); if (lecturer == null) { return(null); } InstructorModel model = new InstructorModel { Id = lecturer.Id, Login = lecturer.User.Login, FirstName = lecturer.User.Firstname, LastName = lecturer.User.Lastname, PESEL = lecturer.User.Pesel, Address = lecturer.User.Address, City = lecturer.User.City, Code = lecturer.Code, DateOfBirth = lecturer.User.Dateofbirth, UserId = lecturer.Userid, UserType = (UserTypes)lecturer.User.Usertype, }; return(model); } }
public void TestInit() { _classesController.Request = new HttpRequestMessage(HttpMethod.Get, APIURL + "Classes"); _classesController.Configuration = new HttpConfiguration(); _classesController.Configuration.Routes.MapHttpRoute( name: ROUTENAME, routeTemplate: ROUTETEMPLATE, defaults: new { id = RouteParameter.Optional }); _value = Helper.GetNewValue(); var instructorName = new InstructorModel { FirstName = _value, MiddleName = _value, LastName = _value, Organization = _organization, }; _instructorsController.Request = new HttpRequestMessage(HttpMethod.Post, APIURL + "Instructors"); _instructorsController.Request.Content = new StringContent(EnrollMe.Controllers.Helper.SerializeJson(instructorName)); _instructorsController.Request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); _instructorsController.Configuration = new HttpConfiguration(); _instructorsController.Configuration.Routes.MapHttpRoute( name: ROUTENAME, routeTemplate: ROUTETEMPLATE, defaults: new { id = RouteParameter.Optional }); var response = _instructorsController.Post(instructorName); var data = ((APIResponse)(((System.Net.Http.ObjectContent)(response.Content)).Value)).Data; _instructorId = (data.ReturnModel as EnrollMeDB.Instructors).InstructorId; }
public List <SelectListItem> getClassSelectList(InstructorModel instructor) { List <ClassModel> classes = new List <ClassModel>(); List <SelectListItem> newClasses = new List <SelectListItem>(); List <InstrctrClassJoin> instClasses = db.instructorClassJoin.ToList(); List <ClassModel> classes1 = db.classmodel.ToList(); foreach (ClassModel this_class in classes1) { foreach (InstrctrClassJoin a_class in instClasses) { a_class.classModel = db.classmodel.Find(a_class.class_id); if (a_class.instructor_id == instructor.instructor_Id && a_class.class_id == this_class.class_Id) { break; } } newClasses.Add(new SelectListItem() { Text = this_class.className, Value = this_class.class_Id.ToString() }); classes.Add(this_class); } return(newClasses); }
/// <summary> /// Handle AcceptingStudentSubmissions changing (disable when false) /// </summary> /// <param name="sender">The event sender</param> /// <param name="args">The arguments</param> private void HandleAcceptingSSubsChanged(object sender, PropertyEventArgs args) { InstructorModel instructor = null; ParticipantModel participant = null; using (Synchronizer.Lock(this.m_Model.Workspace.CurrentPresentation.SyncRoot)) { if (this.m_Model.Workspace.CurrentPresentation.Value != null) { using (Synchronizer.Lock(this.m_Model.Workspace.CurrentPresentation.Value.SyncRoot)) { participant = this.m_Model.Workspace.CurrentPresentation.Value.Owner; } } } if (participant != null) { using (Synchronizer.Lock(participant.SyncRoot)) { if (participant.Role != null) { instructor = participant.Role as InstructorModel; } } } if (instructor != null) { using (Synchronizer.Lock(instructor.SyncRoot)) { this.Enabled = instructor.AcceptingStudentSubmissions; } } }
public ActionResult Instructor(InstructorModel model) { var department = db.Departments.OrderBy(x => x.DepartmentName); int genNumber = randomInteger.Next(1234567890); if (ModelState.IsValid) { // Attempt to register the user try { WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { SurName = model.SurName, FirstName = model.FirstName, OtherNames = model.OtherNames, EmailAddress = model.EmailAddress, PhoneNumber = model.PhoneNumber, RegistrationType = "Instructor", DepartmentId = model.DepartmentId }); WebSecurity.Login(model.UserName, model.Password); if (!Roles.RoleExists("Instructor")) { Roles.CreateRole("Instructor"); } Roles.AddUsersToRoles(new[] { model.UserName }, new[] { "Instructor" }); return(RedirectToAction("Index", "Profile")); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); ViewBag.DepartmentId = new SelectList(department, "DepartmentId", "DepartmentInfo", model.DepartmentId); return(View(model)); } } ViewBag.DepartmentId = new SelectList(department, "DepartmentId", "DepartmentInfo", model.DepartmentId); return(View(model)); }
public void Instructors_PostDelete() { var instructorModel = new InstructorModel(); //var response = _controller.Post(null); //Assert.AreEqual(response.StatusCode, HttpStatusCode.BadRequest); instructorModel.FirstName = _value; instructorModel.MiddleName = _value; instructorModel.LastName = _value; instructorModel.Organization = _organization; _controller.Request.Content = new StringContent(EnrollMe.Controllers.Helper.SerializeJson(instructorModel)); _controller.Request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); var response = _controller.Post(instructorModel); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); var data = ((APIResponse)(((System.Net.Http.ObjectContent)(response.Content)).Value)).Data; Assert.AreEqual((data.ReturnModel as EnrollMeDB.Instructors).LastName, instructorModel.LastName); Assert.IsTrue(((APIResponse)(((System.Net.Http.ObjectContent)(response.Content)).Value)).Links.Count() > 0); _controller.Request.Content = new StringContent(EnrollMe.Controllers.Helper.SerializeJson(instructorModel)); _controller.Request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); response = _controller.Post(instructorModel); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); Assert.AreEqual((data.ReturnModel as EnrollMeDB.Instructors).LastName, instructorModel.LastName); Assert.IsTrue(((APIResponse)(((System.Net.Http.ObjectContent)(response.Content)).Value)).Links.Count() > 0); response = _controller.Delete((data.ReturnModel as EnrollMeDB.Instructors).InstructorId); Assert.AreEqual(1, ((APICommon.APIResponse)(((System.Net.Http.ObjectContent)(response.Content)).Value)).Data.ReturnModel); }
public void ShouldCorrectlySetEntityStatesForAddedObjectGraphWithChildEntity() { //arrange DataFormSettingsDescriptor formDescriptor = Descriptors.InstructorFormWithInlineOfficeAssignment; InstructorModel instructorModel = null; ObservableCollection <IValidatable> modifiedProperties = CreateValidatablesFormSettings(formDescriptor, typeof(InstructorModel)); IDictionary <string, IValidatable> propertiesDictionary = modifiedProperties.ToDictionary(property => property.Name); propertiesDictionary["ID"].Value = 3; propertiesDictionary["FirstName"].Value = "John"; propertiesDictionary["LastName"].Value = "Smith"; propertiesDictionary["HireDate"].Value = new DateTime(2021, 5, 20); propertiesDictionary["OfficeAssignment.Location"].Value = "Location1"; InstructorModel currentInstructor = serviceProvider.GetRequiredService <IEntityStateUpdater>().GetUpdatedModel ( instructorModel, instructorModel.EntityToObjectDictionary ( serviceProvider.GetRequiredService <IMapper>(), formDescriptor.FieldSettings ), modifiedProperties, formDescriptor.FieldSettings ); Assert.Equal(LogicBuilder.Domain.EntityStateType.Added, currentInstructor.EntityState); Assert.Equal(LogicBuilder.Domain.EntityStateType.Added, currentInstructor.OfficeAssignment.EntityState); }
public void MapIValidatableListModelWithPopupOfficeAssignmentToInstructor() { //arrange ObservableCollection <IValidatable> properties = serviceProvider.GetRequiredService <IFieldsCollectionBuilder>().CreateFieldsCollection ( Descriptors.InstructorFormWithPopupOfficeAssignment, typeof(InstructorModel) ).Properties; IDictionary <string, IValidatable> propertiesDictionary = properties.ToDictionary(property => property.Name); propertiesDictionary["ID"].Value = 3; propertiesDictionary["FirstName"].Value = "John"; propertiesDictionary["LastName"].Value = "Smith"; propertiesDictionary["HireDate"].Value = new DateTime(2021, 5, 20); propertiesDictionary["OfficeAssignment"].Value = new OfficeAssignmentModel { Location = "Location1" }; propertiesDictionary["Courses"].Value = new ObservableCollection <CourseAssignmentModel> ( new List <CourseAssignmentModel> { new CourseAssignmentModel { CourseID = 1, InstructorID = 2, CourseTitle = "Chemistry" }, new CourseAssignmentModel { CourseID = 2, InstructorID = 2, CourseTitle = "Physics" }, new CourseAssignmentModel { CourseID = 2, InstructorID = 2, CourseTitle = "Mathematics" } } ); //act InstructorModel instructorModel = serviceProvider.GetRequiredService <IEntityStateUpdater>().GetUpdatedModel ( (InstructorModel)null, new Dictionary <string, object>(), properties, Descriptors.InstructorFormWithPopupOfficeAssignment.FieldSettings ); //assert Assert.Equal(3, instructorModel.ID); Assert.Equal("John", instructorModel.FirstName); Assert.Equal("Smith", instructorModel.LastName); Assert.Equal(new DateTime(2021, 5, 20), instructorModel.HireDate); Assert.Equal("Location1", instructorModel.OfficeAssignment.Location); Assert.Equal("Chemistry", instructorModel.Courses.First().CourseTitle); }
public void MapInstructorModelToIValidatableListWithPopupOfficeAssignment() { //arrange InstructorModel instructor = new InstructorModel { ID = 3, FirstName = "John", LastName = "Smith", HireDate = new DateTime(2021, 5, 20), OfficeAssignment = new OfficeAssignmentModel { Location = "Location1" }, Courses = new List <CourseAssignmentModel> { new CourseAssignmentModel { CourseID = 1, InstructorID = 2, CourseTitle = "Chemistry" }, new CourseAssignmentModel { CourseID = 2, InstructorID = 3, CourseTitle = "Physics" }, new CourseAssignmentModel { CourseID = 3, InstructorID = 4, CourseTitle = "Mathematics" } } }; ObservableCollection <IValidatable> properties = serviceProvider.GetRequiredService <IFieldsCollectionBuilder>().CreateFieldsCollection ( Descriptors.InstructorFormWithPopupOfficeAssignment, typeof(InstructorModel) ).Properties; //act serviceProvider.GetRequiredService <IPropertiesUpdater>().UpdateProperties ( properties, instructor, Descriptors.InstructorFormWithPopupOfficeAssignment.FieldSettings ); //assert IDictionary <string, object> propertiesDictionary = properties.ToDictionary(property => property.Name, property => property.Value); Assert.Equal(3, propertiesDictionary["ID"]); Assert.Equal("John", propertiesDictionary["FirstName"]); Assert.Equal("Smith", propertiesDictionary["LastName"]); Assert.Equal(new DateTime(2021, 5, 20), propertiesDictionary["HireDate"]); Assert.Equal("Location1", ((OfficeAssignmentModel)propertiesDictionary["OfficeAssignment"]).Location); Assert.Equal("Chemistry", ((IEnumerable <CourseAssignmentModel>)propertiesDictionary["Courses"]).First().CourseTitle); }
public ActionResult DeleteConfirmed(int id) { InstructorModel instructorModel = db.instructorModel.Find(id); db.instructorModel.Remove(instructorModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public void MapIValidatableListModelWithPopupOfficeAssignmentToInstructor() { //arrange ObservableCollection <IValidatable> properties = new ObservableCollection <IValidatable>(); new FieldsCollectionHelper ( Descriptors.InstructorFormWithPopupOfficeAssignment, properties, new UiNotificationService(), new HttpServiceMock(), serviceProvider.GetRequiredService <IMapper>() ).CreateFieldsCollection(); IDictionary <string, IValidatable> propertiesDictionary = properties.ToDictionary(property => property.Name); propertiesDictionary["ID"].Value = 3; propertiesDictionary["FirstName"].Value = "John"; propertiesDictionary["LastName"].Value = "Smith"; propertiesDictionary["HireDate"].Value = new DateTime(2021, 5, 20); propertiesDictionary["OfficeAssignment"].Value = new OfficeAssignmentModel { Location = "Location1" }; propertiesDictionary["Courses"].Value = new ObservableCollection <CourseAssignmentModel> ( new List <CourseAssignmentModel> { new CourseAssignmentModel { CourseID = 1, InstructorID = 2, CourseTitle = "Chemistry" }, new CourseAssignmentModel { CourseID = 2, InstructorID = 2, CourseTitle = "Physics" }, new CourseAssignmentModel { CourseID = 2, InstructorID = 2, CourseTitle = "Mathematics" } } ); //act InstructorModel instructorModel = (InstructorModel)properties.ToModelObject(typeof(InstructorModel), serviceProvider.GetRequiredService <IMapper>(), Descriptors.InstructorFormWithPopupOfficeAssignment.FieldSettings); //assert Assert.Equal(3, instructorModel.ID); Assert.Equal("John", instructorModel.FirstName); Assert.Equal("Smith", instructorModel.LastName); Assert.Equal(new DateTime(2021, 5, 20), instructorModel.HireDate); Assert.Equal("Location1", instructorModel.OfficeAssignment.Location); Assert.Equal("Chemistry", instructorModel.Courses.First().CourseTitle); }
public ActionResult Edit(InstructorModel instructorModel) { if (ModelState.IsValid) { db.Entry(instructorModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(instructorModel)); }
/// <summary> /// deletes a Instructor from the db then returns to Instructor list in admin /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult DeleteInstructor(InstructorModel model) { if (model != null) { db.InstructorModels.Attach(model); db.InstructorModels.Remove(model); db.SaveChanges(); } return(RedirectToAction("LoadInstructors")); }
public TCPServer(IPEndPoint localEP, PresenterModel model, ClassroomModel classroom, InstructorModel instructor) { string portStr = System.Configuration.ConfigurationManager.AppSettings[this.GetType().ToString() + ".TCPListenPort"]; int p; if (Int32.TryParse(portStr, out p)) { TCPListenPort = p; } RestoreConfig(); m_ClientConnected = new ManualResetEvent(false); m_Participant = model.Participant; m_Classroom = classroom; m_ClientCount = 0; this.m_Network = model.Network; m_NetworkStatus = new NetworkStatus(ConnectionStatus.Disconnected, ConnectionProtocolType.TCP, TCPRole.Server, 0); this.m_Network.RegisterNetworkStatusProvider(this, true, m_NetworkStatus); if (localEP != null) { this.m_ListenEP = localEP; } else { IPAddress ip = IPAddress.Any; //Use IPv4 unless it is unavailable. TODO: Maybe this should be a configurable parameter? if ((!Socket.OSSupportsIPv4) && (Socket.OSSupportsIPv6)) { ip = IPAddress.IPv6Any; } this.m_ListenEP = new IPEndPoint(ip, TCPListenPort); } m_AllClients = new Hashtable(); m_ReceiveQueue = new Queue(); this.m_Encoder = new Chunk.ChunkEncoder(); this.m_ServerSender = new TCPServerSender(instructor); //Start bridging if config file says so #if RTP_BUILD m_U2MBridge = null; string enableBridge = System.Configuration.ConfigurationManager.AppSettings[this.GetType().ToString() + ".EnableBridge"]; if (enableBridge != null) { bool enable = false; if (bool.TryParse(enableBridge, out enable) && enable) { Trace.WriteLine("Unicast to Multicast Bridge enabled.", this.GetType().ToString()); m_U2MBridge = new UnicastToMulticastBridge(model); } } #endif }
/// <summary> /// Initates editing of the selected Instructor record /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult InstructorEditView(int?id) { var model = new InstructorModel(); if (id != null) { model = db.InstructorModels.Find(id); model.PasswordShield = "*************"; } return(View(model)); }
public async Task <bool> BecomeAnInstructor(InstructorModel instructor) { var httpClient = new HttpClient(); var json = JsonConvert.SerializeObject(instructor); var content = new StringContent(json, Encoding.UTF8, "application/json"); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", Preferences.Get(Constants.Access_Token, string.Empty)); var response = await httpClient.PostAsync("https://teachify.azurewebsites.net/api/instructors", content); return(response.StatusCode == HttpStatusCode.Created); }
public IActionResult RegisterInstructor([FromBody] InstructorModel model) { if (ModelState.IsValid) { string errorMessage = string.Empty; if (service.RegisterInstructor(model, ref errorMessage)) { return(Json(new Result(true))); } return(Json(new Result(errorMessage))); } return(Json(new Result(ModelState.GetFirstError()))); }
public void ShouldCorrectlySetEntityStatesForExistingChildEntity() { //arrange EditFormSettingsDescriptor formDescriptor = Descriptors.InstructorFormWithInlineOfficeAssignment; InstructorModel instructorModel = new InstructorModel { ID = 3, FirstName = "John", LastName = "Smith", HireDate = new DateTime(2021, 5, 20), OfficeAssignment = new OfficeAssignmentModel { Location = "Location1" } }; ObservableCollection <IValidatable> modifiedProperties = CreateValidatablesFromSettings(formDescriptor); IDictionary <string, IValidatable> propertiesDictionary = modifiedProperties.ToDictionary(property => property.Name); propertiesDictionary["ID"].Value = 3; propertiesDictionary["FirstName"].Value = "John"; propertiesDictionary["LastName"].Value = "Smith"; propertiesDictionary["HireDate"].Value = new DateTime(2021, 5, 20); propertiesDictionary["OfficeAssignment.Location"].Value = "Location1"; IMapper mapper = serviceProvider.GetRequiredService <IMapper>(); Dictionary <string, object> existing = instructorModel.EntityToObjectDictionary ( mapper, formDescriptor.FieldSettings ); Dictionary <string, object> current = modifiedProperties.ValidatableListToObjectDictionary ( mapper, formDescriptor.FieldSettings ); EntityMapper.UpdateEntityStates ( existing, current, formDescriptor.FieldSettings ); InstructorModel currentInstructor = mapper.Map <InstructorModel>(current); Assert.Equal(LogicBuilder.Domain.EntityStateType.Unchanged, currentInstructor.EntityState); Assert.Equal(LogicBuilder.Domain.EntityStateType.Unchanged, currentInstructor.OfficeAssignment.EntityState); }
public InstructorMessage(InstructorModel role) : base(role) { using (Synchronizer.Lock(role.SyncRoot)) { this.AcceptingStudentSubmissions = role.AcceptingStudentSubmissions; // Need to add as an extension to maintain backward compatability this.Extension = new ExtensionWrapper(role.AcceptingQuickPollSubmissions, new Guid("{65A946F4-D1C5-426b-96DB-7AF4863CE296}")); ((ExtensionWrapper)this.Extension).AddExtension(new ExtensionWrapper(role.AcceptingQuickPollSubmissions, new Guid("{65A946F4-D1C5-426b-96DB-7AF4863CE296}"))); ((ExtensionWrapper)this.Extension).AddExtension(new ExtensionWrapper(role.StudentNavigationType, new Guid("{4795707C-9F85-CA1F-FEBA-5E851CF9E1DE}"))); this.AcceptingQuickPollSubmissions = role.AcceptingQuickPollSubmissions; this.ForcingStudentNavigationLock = role.ForcingStudentNavigationLock; this.InstructorClockTicks = UW.ClassroomPresenter.Misc.AccurateTiming.Now; this.StudentNavigationType = role.StudentNavigationType; } }
public ActionResult AddOrEdit(InstructorModel emp) { if (emp.Instructor_ID == 0) { HttpResponseMessage response = GlobalVariables.WebApiClient.PostAsJsonAsync("INSTRUCTORs", emp).Result; TempData["SuccessMessage"] = "Saved Successfully"; } else { HttpResponseMessage response = GlobalVariables.WebApiClient.PutAsJsonAsync("INSTRUCTORs/" + emp.Instructor_ID, emp).Result; TempData["SuccessMessage"] = "Updated Successfully"; } return(RedirectToAction("Index")); }
public IActionResult UpdateInstructor([FromBody] InstructorModel model) { model.SkipPasswordValidation(ModelState); if (ModelState.IsValid) { string errorMessage = string.Empty; if (service.UpdateInstructor(model, ref errorMessage)) { return(Json(new Result(true))); } return(Json(new Result(errorMessage))); } return(Json(new Result(ModelState.GetFirstError()))); }
// GET: Instructor/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InstructorModel instructorModel = db.instructorModel.Find(id); if (instructorModel == null) { return(HttpNotFound()); } return(View(instructorModel)); }
protected override bool UpdateTarget(ReceiveContext context) { bool update = base.UpdateTarget(context); InstructorModel instructor = this.Parent != null ? this.Parent.Target as InstructorModel : null; if (instructor != null) { using (Synchronizer.Lock(instructor.SyncRoot)) { instructor.CurrentDeckTraversal = this.Target as DeckTraversalModel; } } return(update); }
protected override bool SetUp(int index, DeckTraversalModel traversal, out DeckTabPage page) { Debug.Assert(!this.m_Owner.InvokeRequired); Debug.Assert(this.m_Owner.IsHandleCreated); page = new DeckTabPage(traversal, this.m_Owner.m_Model); page.AutoScrollChanged += new AutoScrollEventHandler(this.m_Owner.OnAutoScrollChanged); this.m_Owner.TabPages.Add(page); this.m_Owner.m_DeckTraversalToTabPageMap.Add(traversal, page); // If there does not already exist a current deck traversal, set it. // FIXME: This really should be done by a separate "service" class. This logic is shared with FilmStripSlideViewer.OnMouseUp. // FIXME: Unset the workspace's deck traversal if the deck is ever removed from the workspace in the future. // Consider keeping a global list of DeckTraversalModels and update the Workspace when DTMs are added to the list. // NOTE: Using a temporary variable IsInstructor to resolve lock ordering issue. // We don't want to lock the workspace model after the participant model in our code. bool IsInstructor = false; using (Synchronizer.Lock(this.m_Owner.m_Model.Participant.SyncRoot)) { // If the user's role is an InstructorModel, set the InstructorModel's CurrentDeckTraversal. // The NetworkAssociationService will then use this to set the WorkspaceModel's CurrentDeckTraversal, // and the new deck traversal will also be broadcast. InstructorModel instructor = this.m_Owner.m_Model.Participant.Role as InstructorModel; if (instructor != null) { IsInstructor = true; using (Synchronizer.Lock(instructor.SyncRoot)) { if (instructor.CurrentDeckTraversal == null) { instructor.CurrentDeckTraversal = traversal; } } } } if (!IsInstructor) { // Otherwise, we must set the CurrentDeckTraversal on the WorkspaceModel directly. using (this.m_Owner.m_Model.Workspace.Lock()) { if (this.m_Owner.m_Model.Workspace.CurrentDeckTraversal == null) { this.m_Owner.m_Model.Workspace.CurrentDeckTraversal.Value = traversal; } } } return(true); }
/// <summary> /// Constructor /// </summary> /// <param name="sender">The sending queue to post messages to</param> /// <param name="role">The InstructorModel to create this class for</param> public InstructorWebService(SendingQueue sender, InstructorModel role) { this.m_Sender = sender; this.m_Instructor = role; // Handle basic changes this.m_GenericChangeDispatcher = new EventQueue.PropertyEventDispatcher(this.m_Sender, new PropertyEventHandler(this.HandleGenericChange)); this.m_Instructor.Changed["ForcingStudentNavigationLock"].Add(this.m_GenericChangeDispatcher.Dispatcher); this.m_Instructor.Changed["AcceptingStudentSubmissions"].Add(this.m_GenericChangeDispatcher.Dispatcher); this.m_Instructor.Changed["AcceptingQuickPollSubmissions"].Add(this.m_GenericChangeDispatcher.Dispatcher); // Handle changes to the current deck traversal this.m_CurrentDeckTraversalChangedDispatcher = new EventQueue.PropertyEventDispatcher(this.m_Sender, new PropertyEventHandler(this.HandleCurrentDeckTraversalChanged)); this.m_Instructor.Changed["CurrentDeckTraversal"].Add(this.m_CurrentDeckTraversalChangedDispatcher.Dispatcher); this.m_CurrentDeckTraversalChangedDispatcher.Dispatcher(this, null); }
public ActionResult addToClass(int?id) { if (id == null) { return(RedirectToAction("Index")); } else { InstructorClassJoinModel joinModel = new InstructorClassJoinModel(); InstructorModel instructor = db.instructorModel.Find(id); joinModel.instructor = instructor; joinModel.instructor_Id = Convert.ToInt16(id); joinModel.classes = getClassSelectList(instructor); return(View(joinModel)); } }