public async Task UpdateOrAddTeacherPageAsync(TeacherPage teacherPage) { try { var teacherToUpdate = await dbContext.TeacherPages.FindAsync(teacherPage.ID); if (teacherToUpdate == null) { await this.AddTeacherPageAsync(teacherPage); } else { teacherToUpdate.OfficePlace = teacherPage.OfficePlace; teacherToUpdate.PersonalUrl = teacherPage.PersonalUrl; teacherToUpdate.TeachingAge = teacherPage.TeachingAge; teacherToUpdate.PosTitle = teacherPage.PosTitle; teacherToUpdate.Status = teacherPage.Status; await this.UpdateTeacherPageAsync(teacherToUpdate); } } catch (Exception e) { logger.LogError(e.Message); throw new Exception("Action Failed"); } }
public async Task <dynamic> OnUpdateTeacherPageAsync([FromForm] TeacherPage teacherPage, [FromForm] string token) { try { var t = await tokenService.GetTokenAsync(token); if (t == null) { throw new Exception("请先登录"); } if (t.Role != UserRole.Admin) { if (t.Role != UserRole.Teacher || t.UserID != teacherPage.ID) { throw new Exception("权限不足"); } } await userService.UpdateOrAddTeacherPageAsync(teacherPage); return(new { Res = true }); } catch (Exception e) { return(new { Res = false, Error = e.Message }); } }
private void btn_1_Clicked(object sender, EventArgs e) { if (TeacherPage.lastClicked != null) { TeacherPage.list.Remove(TeacherPage.lastClicked); TeacherPage.lastClicked = null; TeacherPage.tp.DisableButton(); Navigation.PopPopupAsync(); TeacherPage.RefreshData(); TeacherPage.tp.RefreshSch(); } }
public async Task UpdateTeacherPageAsync(TeacherPage teacherPage) { try { dbContext.TeacherPages.Update(teacherPage); await dbContext.SaveChangesAsync(); } catch (Exception e) { logger.LogError(e.Message); throw new Exception("Action Failed"); } }
static private void LoginUser(Window window, AbstractUser user) { Window w = null; if (user is AdminAccount) { w = new AdminPage((AdminAccount)user); } else if (user is TeacherAccount) { w = new TeacherPage((TeacherAccount)user); } if (w != null) { w.Show(); window.Close(); } }
private void Button_Clicked(object sender, EventArgs e) { if (item == null && (iday.SelectedIndex == 0 || iclass.SelectedIndex == 0 || iroom.SelectedIndex == 0)) { new Popup(new ErrorMessage("Fyll i alla fälten."), TeacherPage.tp).Show(); return; } if (item == null) { for (int x = 0; x < TeacherPage.list.Count; x++) { var _a = TeacherPage.list[x]; if (_a.LecDay == iday.SelectedItem.ToString() && _a.LecTime == App.GetTime(itime.Time, false)) { new Popup(new ErrorMessage("Det finns redan en lektion med samma tid!"), TeacherPage.tp).Show(); return; } } } ListItem newItem = new ListItem { LecDay = iday.SelectedItem.ToString(), LecTime = App.GetTime(itime.Time, false), ItemColor = item != null?item.ItemColor:App.UNCLICKED, Class = iclass.SelectedItem.ToString(), Room = iroom.SelectedItem.ToString() }; if (item != null) { var _index = _Get(item); TeacherPage.list.RemoveAt(_index); TeacherPage.list.Insert(_index, newItem); TeacherPage.lastClicked = newItem; } else { TeacherPage.list.Add(newItem); } Navigation.PopPopupAsync(); TeacherPage.RefreshData(); TeacherPage.tp.RefreshSch(); }