public async Task <IActionResult> Edit(int id, [Bind("ExamPrice,Id,Surname,Name,Patronymic,Photo,PhotoPath")] ExaminerViewModel examinerViewModel) { if (id != examinerViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { Examiner examiner = new Examiner { Id = examinerViewModel.Id, Surname = examinerViewModel.Surname, Name = examinerViewModel.Name, Patronymic = examinerViewModel.Patronymic, ExamPrice = examinerViewModel.ExamPrice, Photo = examinerViewModel.PhotoPath }; if (examinerViewModel.Photo != null) { var fileName = UploadedFile(examinerViewModel); examiner.Photo = fileName; } _context.Update(examiner); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(examinerViewModel)); }
public void TestExaminer() { Examiner examiner = new Examiner() { Id = 1, Name = "Илья", SurName = "Шутов", Patronymic = "Борисович", Examen = "Математика", Examen_2 = "Информатика" }; Examiner examiner2 = new Examiner() { Id = 1, Name = "Илья", SurName = "Шутов", Patronymic = "Борисович", Examen = "Математика", Examen_2 = "Информатика" }; string except = "1 Шутов Илья Борисович Математика Информатика"; int except_properties = 6; Assert.IsTrue(examiner.Equals(examiner2)); Assert.AreEqual(except, examiner.ToString()); Assert.AreEqual(except_properties, examiner.GetHashCode()); }
public void TestAddDeleteToDatabaseExaminer() { Examiner examiner = new Examiner { Id = 5, Name = "Илья", SurName = "Шутов", Patronymic = "Борисович", Examen = "Математика", Examen_2 = "Информатика" }; AddToDataBase add = new AddToDataBase(); add.AddNewExaminer(examiner); DataContext db = new DataContext(connectionString); Examiner ex = db.GetTable <Examiner>().OrderByDescending(u => u.Id).FirstOrDefault(); var except_EndElement = true; var actual_EndElement = examiner.Equals(ex); DeleteToDataBase del = new DeleteToDataBase(); del.DeleteEndExaminer(); ex = db.GetTable <Examiner>().OrderByDescending(u => u.Id).FirstOrDefault(); var except_EndElement_2 = false; var actual_EndElement_2 = examiner.Equals(ex); Assert.AreEqual(except_EndElement, actual_EndElement); Assert.AreEqual(except_EndElement_2, actual_EndElement_2); }
public void TestingUpdateDatabase() { string new_ex = "ОС"; Examiner ex = new Examiner() { Id = 1, Name = "Константин", SurName = "Курочка", Patronymic = "Сергеевич", Examen = "ООП", Examen_2 = new_ex }; UpdateDataBase update = new UpdateDataBase(); update.UpdateFirstExaminer(ex); DataContext db = new DataContext(connectionString); Examiner res = db.GetTable <Examiner>().FirstOrDefault(); var except = true; var actual = ex.Equals(res); // возврат начальных значений ex.Examen_2 = "КС"; update.UpdateFirstExaminer(ex); Assert.AreEqual(except, actual); }
void InitializeGame() { score = new Scorer(); examiner = new Examiner(InitialLevel); spawner.Reset(); StartLevel(); }
public ActionResult DeleteConfirmed(int id) { Examiner examiner = db.Examiners.Find(id); db.Examiners.Remove(examiner); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ExaminerID,InstituteAdminID,UserName")] Examiner examiner) { if (ModelState.IsValid) { db.Entry(examiner).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.InstituteAdminID = new SelectList(db.InstituteAdmins, "InstituteAdminID", "InsAdminName", examiner.InstituteAdminID); return(View(examiner)); }
public ActionResult Create([Bind(Include = "ExaminerID,InstituteAdminID,UserName")] Examiner examiner) { if (ModelState.IsValid) { db.Examiners.Add(examiner); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.InstituteAdminID = new SelectList(db.InstituteAdmins, "InstituteAdminID", "InsAdminName", examiner.InstituteAdminID); return(PartialView(examiner)); }
private async Task LoadAsync(Examiner user) { var email = await _userManager.GetEmailAsync(user); Email = email; Input = new InputModel { NewEmail = email, }; IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user); }
private async Task LoadAsync(Examiner user) { var userName = await _userManager.GetUserNameAsync(user); var phoneNumber = await _userManager.GetPhoneNumberAsync(user); Username = userName; Input = new InputModel { PhoneNumber = phoneNumber }; }
public void IdentifyBlocksThatIfRemovedWouldCreateLargerSets() { List <Set> s = new List <Set>(); // Create a situation where a single file has two redundant // sets, each set having two blocks. Like so: /* 1 * 2 public void Foo() * 3 { * 4 //////////////////////////////// * 5 ////// Redundant set Top /////// * 6 //////////////////////////////// * 7 --> Foo extract method candidate <-- * 8 //////////////////////////////// * 9 ////// Redundant set Bottom //// * 10 //////////////////////////////// * 11 } * 12 public void Bar() * 13 { * 14 //////////////////////////////// * 15 ////// Redundant set Top /////// * 16 //////////////////////////////// * 17 --> Bar extract method candidate <-- * 18 //////////////////////////////// * 19 ////// Redundant set Bottom //// * 20 //////////////////////////////// * 21 } * 22 * * If the two --><-- sections were removed, the two sets would * become one big set. */ s.Add(new Set(3)); s[0].AddBlock("SampleRedundantFile.cs", 4); s[0].AddBlock("SampleRedundantFile.cs", 14); s.Add(new Set(3)); s[1].AddBlock("SampleRedundantFile.cs", 8); s[1].AddBlock("SampleRedundantFile.cs", 18); Examiner e = new Examiner(null); List <ISet> candidates = e.Examine(s); Assert.AreEqual(1, candidates.Count); Assert.AreEqual(7, candidates[0].Blocks[0].StartLineNumber); Assert.AreEqual(7, candidates[0].Blocks[0].EndLineNumber); Assert.AreEqual(17, candidates[0].Blocks[1].StartLineNumber); Assert.AreEqual(17, candidates[0].Blocks[1].EndLineNumber); }
// GET: Examiner/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Examiner examiner = db.Examiners.Find(id); if (examiner == null) { return(HttpNotFound()); } return(View(examiner)); }
// GET: Examiner/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Examiner examiner = db.Examiners.Find(id); if (examiner == null) { return(HttpNotFound()); } ViewBag.InstituteAdminID = new SelectList(db.InstituteAdmins, "InstituteAdminID", "InsAdminName", examiner.InstituteAdminID); return(View(examiner)); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var user = new Examiner { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl })); } else { await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
public void AddExaminer(Examiner examiner) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectionString)) { string sql = "dbo.AddAddress @City, @State, @Country, @Zipcode"; int address_id = connection.Query <int>(sql, examiner.Address).Single(); sql = "dbo.AddExaminer @Name, @Surname, @Pesel, @BirthDate, @Address_Id"; var e = new { Name = examiner.Name, Surname = examiner.Surname, Pesel = examiner.Pesel, BirthDate = examiner.BirthDate, Address_Id = address_id }; int examiner_id = connection.Query <int>(sql, e).Single(); foreach (string category in examiner.Permissions) { sql = "dbo.AddCategory @Examiner_Id, @Category"; var p = new { Examiner_Id = examiner_id, Category = category }; connection.Execute(sql, p); } } }
private async Task LoadSharedKeyAndQrCodeUriAsync(Examiner user) { // Load the authenticator key & QR code URI to display on the form var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); if (string.IsNullOrEmpty(unformattedKey)) { await _userManager.ResetAuthenticatorKeyAsync(user); unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); } SharedKey = FormatKey(unformattedKey); var email = await _userManager.GetEmailAsync(user); AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey); }
public void BlocksInDifferentFilesCantBeConsecutive() { List<Set> s = new List<Set>(); // Same block defs as above, except the sets are in different files, // and therefore will never be consecutive. s.Add(new Set(3)); s[0].AddBlock("SampleRedundantFile.cs", 4); s[0].AddBlock("SampleRedundantFile.cs", 14); s.Add(new Set(3)); s[1].AddBlock("DifferentFile.cs", 8); s[1].AddBlock("DifferentFile.cs", 18); Examiner e = new Examiner(null); List<ISet> candidates = e.Examine(s); Assert.IsEmpty(candidates); }
private void executeAdd(object obj) { var address = new Address { City = City, Country = Country, Zipcode = Zipcode, State = State }; var examiner = new Examiner { Name = Name, Surname = Surname, Pesel = Pesel, BirthDate = (DateTime)BirthDate, Address = address }; examiner.Permissions.Add(Category); db.AddExaminer(examiner); Name = null; Surname = null; Pesel = null; BirthDate = null; City = null; State = null; Zipcode = null; Country = null; }
public void BlocksInDifferentFilesCantBeConsecutive() { List <Set> s = new List <Set>(); // Same block defs as above, except the sets are in different files, // and therefore will never be consecutive. s.Add(new Set(3)); s[0].AddBlock("SampleRedundantFile.cs", 4); s[0].AddBlock("SampleRedundantFile.cs", 14); s.Add(new Set(3)); s[1].AddBlock("DifferentFile.cs", 8); s[1].AddBlock("DifferentFile.cs", 18); Examiner e = new Examiner(null); List <ISet> candidates = e.Examine(s); Assert.IsEmpty(candidates); }
public async Task <IActionResult> Create([Bind("ExamPrice,Id,Surname,Name,Patronymic,Photo")] ExaminerViewModel examinerViewModel) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(examinerViewModel); Examiner examiner = new Examiner { Surname = examinerViewModel.Surname, Name = examinerViewModel.Name, Patronymic = examinerViewModel.Patronymic, Photo = uniqueFileName, ExamPrice = examinerViewModel.ExamPrice }; _context.Add(examiner); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(examinerViewModel)); }
public void BlocksInSetNotInFileOrder() { List<Set> s = new List<Set>(); // Exact same as the other test, except the blocks are not in file order. s.Add(new Set(3)); s[0].AddBlock("SampleRedundantFile.cs", 14); s[0].AddBlock("SampleRedundantFile.cs", 4); s.Add(new Set(3)); s[1].AddBlock("SampleRedundantFile.cs", 18); s[1].AddBlock("SampleRedundantFile.cs", 8); Examiner e = new Examiner(null); List<ISet> candidates = e.Examine(s); Assert.AreEqual(17, candidates[0].Blocks[0].StartLineNumber); Assert.AreEqual(17, candidates[0].Blocks[0].EndLineNumber); Assert.AreEqual(7, candidates[0].Blocks[1].StartLineNumber); Assert.AreEqual(7, candidates[0].Blocks[1].EndLineNumber); }
public void BlocksInSetNotInFileOrder() { List <Set> s = new List <Set>(); // Exact same as the other test, except the blocks are not in file order. s.Add(new Set(3)); s[0].AddBlock("SampleRedundantFile.cs", 14); s[0].AddBlock("SampleRedundantFile.cs", 4); s.Add(new Set(3)); s[1].AddBlock("SampleRedundantFile.cs", 18); s[1].AddBlock("SampleRedundantFile.cs", 8); Examiner e = new Examiner(null); List <ISet> candidates = e.Examine(s); Assert.AreEqual(17, candidates[0].Blocks[0].StartLineNumber); Assert.AreEqual(17, candidates[0].Blocks[0].EndLineNumber); Assert.AreEqual(7, candidates[0].Blocks[1].StartLineNumber); Assert.AreEqual(7, candidates[0].Blocks[1].EndLineNumber); }
public async Task <List <Exam> > GetFutureExams(Examiner examiner = null, Examinee examinee = null, string category = null, DateTime?date = null) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectionString)) { string sql = "dbo.GetFutureExams @Examiner_Id, @Examinee_Id, @Category, @Date"; int? examiner_id = examiner == null ? null : (int?)examiner.Id; int? examinee_id = examinee == null ? null : (int?)examinee.Id; var p = new { Examiner_Id = examiner_id, Examinee_Id = examinee_id, Category = category, Date = date }; var exams = await connection.QueryAsync <Exam, int, int, Exam>(sql, (exam, ee_id, er_id) => { var x = GetExamineeById(ee_id); var y = GetExaminerById(er_id); exam.Examinee = x; exam.Examiner = y; return(exam); }, param : p, splitOn : "Examinee_Id, Examiner_Id"); return(exams.ToList()); } }
private void Initialize(GameObject go, bool renderOK = true) { this.Tile = string.Empty; this.RenderString = string.Empty; this.BackgroundString = string.Empty; this.DetailColorChar = 'k'; this.ForegroundColorChar = 'y'; this.BackgroundColorChar = 'k'; this.DetailColor = ConsoleLib.Console.ColorUtility.ColorMap['k']; this.ForegroundColor = ConsoleLib.Console.ColorUtility.ColorMap['y']; this.BackgroundColor = ConsoleLib.Console.ColorUtility.ColorMap['k']; //gather render data for GameObject similar to how the game does it in Cell.cs Render pRender = go?.pRender; if (pRender == null || !pRender.Visible || Globals.RenderMode != RenderModeType.Tiles) { return; } RenderEvent renderData = new RenderEvent(); Examiner examinerPart = go.GetPart <Examiner>(); if (examinerPart != null && !string.IsNullOrEmpty(examinerPart.UnknownTile) && !go.Understood()) { renderData.Tile = examinerPart.UnknownTile; } else { renderData.Tile = go.pRender.Tile; } if (!string.IsNullOrEmpty(pRender.TileColor)) { renderData.ColorString = pRender.TileColor; } else { renderData.ColorString = pRender.ColorString; } if (renderOK) //we can't render blueprint-created objects, because the game will throw errors trying to check their current cell { go.Render(renderData); } //renderData.Tile can be null if something has a temporary character replacement, like the up arrow from flying this.Tile = !string.IsNullOrEmpty(renderData.Tile) ? renderData.Tile : pRender.Tile; this.RenderString = !string.IsNullOrEmpty(renderData.RenderString) ? renderData.RenderString : pRender.RenderString; this.BackgroundString = renderData.BackgroundString; ////DEBUG //UnityEngine.Debug.Log("Render data from GameObject.Render() for " + go.DisplayName + ":\n Tile=" + renderData.Tile // + "\n ColorString=" + renderData.ColorString // + "\n DetailColor=" + renderData.DetailColor // + "\n RenderString=" + renderData.RenderString // + "\n BackgroundString=" + renderData.BackgroundString // + "\nRender data from object itself:" // + "\n Tile=" + pRender.Tile // + "\n RenderString=" + pRender.RenderString // + "\n TileColor=" + pRender.TileColor // + "\n ColorString=" + pRender.ColorString // + "\n DetailColor=" + pRender.DetailColor); ////DEBUG //save render data in our custom TileColorData format, using logic similar to QudItemListElement.InitFrom() if (!string.IsNullOrEmpty(pRender.DetailColor)) { this.DetailColor = ConsoleLib.Console.ColorUtility.ColorMap[pRender.DetailColor[0]]; this.DetailColorChar = pRender.DetailColor[0]; } //from what I've been able to determine, I believe that the BackgroundString only applies to non-tiles (RenderString) entities (such as gas clouds) string colorString = renderData.ColorString + (string.IsNullOrEmpty(this.Tile) ? this.BackgroundString : string.Empty); if (!string.IsNullOrEmpty(colorString)) { for (int j = 0; j < colorString.Length; j++) { if (colorString[j] == '&' && j < colorString.Length - 1) { if (colorString[j + 1] == '&') { j++; } else { this.ForegroundColor = ConsoleLib.Console.ColorUtility.ColorMap[colorString[j + 1]]; this.ForegroundColorChar = colorString[j + 1]; } } if (colorString[j] == '^' && j < colorString.Length - 1) { if (colorString[j + 1] == '^') { j++; } else { this.BackgroundColor = ConsoleLib.Console.ColorUtility.ColorMap[colorString[j + 1]]; this.BackgroundColorChar = colorString[j + 1]; } } } } this.Attributes = ColorUtility.MakeColor(ColorUtility.CharToColorMap[this.ForegroundColorChar], ColorUtility.CharToColorMap[this.BackgroundColorChar]); }
public void IdentifyBlocksThatIfRemovedWouldCreateLargerSets() { List<Set> s = new List<Set>(); // Create a situation where a single file has two redundant // sets, each set having two blocks. Like so: /* 1 * 2 public void Foo() * 3 { * 4 //////////////////////////////// * 5 ////// Redundant set Top /////// * 6 //////////////////////////////// * 7 --> Foo extract method candidate <-- * 8 //////////////////////////////// * 9 ////// Redundant set Bottom //// * 10 //////////////////////////////// * 11 } * 12 public void Bar() * 13 { * 14 //////////////////////////////// * 15 ////// Redundant set Top /////// * 16 //////////////////////////////// * 17 --> Bar extract method candidate <-- * 18 //////////////////////////////// * 19 ////// Redundant set Bottom //// * 20 //////////////////////////////// * 21 } * 22 * * If the two --><-- sections were removed, the two sets would * become one big set. */ s.Add(new Set(3)); s[0].AddBlock("SampleRedundantFile.cs", 4); s[0].AddBlock("SampleRedundantFile.cs", 14); s.Add(new Set(3)); s[1].AddBlock("SampleRedundantFile.cs", 8); s[1].AddBlock("SampleRedundantFile.cs", 18); Examiner e = new Examiner(null); List<ISet> candidates = e.Examine(s); Assert.AreEqual(1, candidates.Count); Assert.AreEqual(7, candidates[0].Blocks[0].StartLineNumber); Assert.AreEqual(7, candidates[0].Blocks[0].EndLineNumber); Assert.AreEqual(17, candidates[0].Blocks[1].StartLineNumber); Assert.AreEqual(17, candidates[0].Blocks[1].EndLineNumber); }
private void Examiner_Focused(object sender, FocusEventArgs e) { Examiner.Unfocus(); }