/// <summary> /// Activate this method when a login is successful to navigate to a MainPage and remove the /// Former pages for the Navigation. /// It will also update all the search filter for the app, and its crucial that they are in this /// method and not just the startup method. /// </summary> public static void SuccessfulLoginAction() { // NavPage.Navigation.PopModalAsync(); DbLocation dbLocation = new DbLocation(); StudyGroupsController sgc = new StudyGroupsController(); LocationsController lc = new LocationsController(); JobTypesController jtc = new JobTypesController(); CoursesController cc = new CoursesController(); NavPage.Navigation.InsertPageBefore(new MainPage(), NavPage.Navigation.NavigationStack.First()); NavPage.Navigation.PopToRootAsync(); if (dbLocation.GetAllLocations().Count != 0) { lc.CompareServerHash(); sgc.CompareServerHash(); jtc.CompareServerHash(); cc.CompareServerHash(); } else { cc.UpdateCoursesFromServer(); jtc.UpdateJobTypesFromServer(); sgc.UpdateStudyGroupsFromServer(); lc.UpdateLocationsFromServer(); } }
protected void gridMain_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { int recSkip = gridMain.CurrentPageIndex * gridMain.PageSize; int recTake = gridMain.PageSize; try { JobTypesController cont = new JobTypesController(); gridMain.VirtualItemCount = cont.CountJobTypes(); gridMain.DataSource = cont.GetJobTypes(recSkip, recTake); } catch (Exception) { } }
private async void TestGetServerHash(object sender, EventArgs e) { StudyGroupsController sgc = new StudyGroupsController(); LocationsController lc = new LocationsController(); JobTypesController jtc = new JobTypesController(); CoursesController cc = new CoursesController(); // this won't work properly with the placeholder backend due to the collation used on that sql database. // but will work if xyzøæå gets sortered properly lc.CompareServerHash(); sgc.CompareServerHash(); jtc.CompareServerHash(); cc.CompareServerHash(); }
public async void Task2_GetById_Return_NotFoundResult() { //Arrange var Id = 32; _context = new SDCContext(dbContextOptions); _controller = new JobTypesController(_context); //Act var result = await _controller.GetJobType(Id); //Assert Assert.IsType <NotFoundResult>(result); }
public async void Task1_GetById_Return_OkResult() { //Arrange var Id = 1; _context = new SDCContext(dbContextOptions); _controller = new JobTypesController(_context); //Act var result = await _controller.GetJobType(Id); //Assert Assert.IsType <OkObjectResult>(result); }
public async void Task4_Put_Update_JobType_NoContentResult() { //Arrange _context = new SDCContext(dbContextOptions); _controller = new JobTypesController(_context); int newId = 6; //Act var jobType = new JobType() { JobId = newId, JobTitle = "Update Mechanic" }; var updatedData = await _controller.PutJobType(newId, jobType); //Assert Assert.IsType <NoContentResult>(updatedData); }
private async void Task5_Delete_JobType_OkResult() { //Arrange _context = new SDCContext(dbContextOptions); _controller = new JobTypesController(_context); var jobType = new JobType() { JobTitle = "New and Del title", }; //Act var resultCreate = await _controller.PostJobType(jobType); var okResult = resultCreate.Should().BeOfType <CreatedAtActionResult>().Subject; var resClient = okResult.Value.Should().BeAssignableTo <JobType>().Subject; int delId = resClient.JobId; var result = await _controller.DeleteJobType(delId); //Assert Assert.IsType <OkObjectResult>(result); }
public async void Task3_Post_NewJobType_JobTitle() { //Arrange _context = new SDCContext(dbContextOptions); _controller = new JobTypesController(_context); var jobType = new JobType() { JobTitle = "Mechanic", }; //Act var result = await _controller.PostJobType(jobType); //Assert var okResult = result.Should().BeOfType <CreatedAtActionResult>().Subject; var resClient = okResult.Value.Should().BeAssignableTo <JobType>().Subject; resClient.JobTitle.Should().Be("Mechanic"); //delete JayNew int newId = _context.JobType.FirstOrDefault(p => p.JobTitle == "Mechanic").JobId; var resultDelete = await _controller.DeleteJobType(newId); }
private void UpdateAllFilters() { // This is to make sure that the app got the study groups that is used as search filters. DbLocation dbLocation = new DbLocation(); StudyGroupsController sgc = new StudyGroupsController(); LocationsController lc = new LocationsController(); JobTypesController jtc = new JobTypesController(); CoursesController cc = new CoursesController(); if (dbLocation.GetAllLocations().Count != 0) { lc.CompareServerHash(); sgc.CompareServerHash(); jtc.CompareServerHash(); cc.CompareServerHash(); } else { cc.UpdateCoursesFromServer(); jtc.UpdateJobTypesFromServer(); sgc.UpdateStudyGroupsFromServer(); lc.UpdateLocationsFromServer(); } }
protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item.OwnerTableView.Name == "Master") { if (e.Item is GridFilteringItem) { GridFilteringItem filterItem = (GridFilteringItem)e.Item; RadDropDownList clist = (RadDropDownList)filterItem.FindControl("ddlJobsMainFilter"); try { JobsMainController jcont = new JobsMainController(); clist.DataSource = jcont.GetJobsMain(); clist.DataTextField = "Name"; clist.DataValueField = "ID"; clist.DataBind(); clist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); } catch (Exception) { } } if (e.Item is GridEditableItem && e.Item.IsInEditMode) { SalesID = -1; Session.Remove("SalesID"); JobsMainID = -1; Session.Remove("JobsMainID"); JobTypesID = -1; Session.Remove("JobTypesID"); GridEditableItem item = e.Item as GridEditableItem; RadDropDownList ddlSale = item.FindControl("ddlSale") as RadDropDownList; RadDropDownList ddlJobsMain = item.FindControl("ddlJobsMain") as RadDropDownList; RadDropDownList ddlJobTypes = item.FindControl("ddlJobTypes") as RadDropDownList; try { JobB currJob = e.Item.DataItem as JobB; SalesController cont = new SalesController(); ddlSale.DataSource = cont.GetSales(); ddlSale.DataTextField = "Name"; ddlSale.DataValueField = "ID"; ddlSale.DataBind(); ddlSale.Items.Insert(0, new DropDownListItem("Χωρίς Έκπτωση", "0")); JobsMainController cont2 = new JobsMainController(); ddlJobsMain.DataSource = cont2.GetJobsMain(); ddlJobsMain.DataTextField = "Name"; ddlJobsMain.DataValueField = "ID"; ddlJobsMain.DataBind(); JobTypesController cont3 = new JobTypesController(); ddlJobTypes.DataSource = cont3.GetJobTypes(); ddlJobTypes.DataTextField = "Name"; ddlJobTypes.DataValueField = "ID"; ddlJobTypes.DataBind(); if (currJob != null) { if (currJob.SalesID != null) { ddlSale.SelectedIndex = ddlSale.FindItemByValue(currJob.SalesID.ToString()).Index; Session["SalesID"] = currJob.SalesID; } else { ddlSale.SelectedIndex = 0; Session["SalesID"] = ddlSale.SelectedItem.Value; } ddlJobsMain.SelectedIndex = ddlJobsMain.FindItemByValue(currJob.JobsMainID.ToString()).Index; Session["JobsMainID"] = currJob.JobsMainID; ddlJobTypes.SelectedIndex = ddlJobTypes.FindItemByValue(currJob.JobTypesID.ToString()).Index; Session["JobTypesID"] = currJob.JobTypesID; } else { ddlSale.SelectedIndex = 0; Session["SalesID"] = ddlSale.SelectedItem.Value; ddlJobsMain.SelectedIndex = 0; Session["JobsMainID"] = ddlJobsMain.SelectedItem.Value; ddlJobTypes.SelectedIndex = 0; Session["JobTypesID"] = ddlJobTypes.SelectedItem.Value; } } catch (Exception) { } } else if (e.Item is GridDataItem) { GridDataItem item = e.Item as GridDataItem; Label lblST = item.FindControl("lblSale") as Label; JobB currJob = e.Item.DataItem as JobB; if (currJob.SalesID == null) { lblST.Text = "Χωρίς Έκπτωση"; } else { lblST.Text = currJob.Sale.Name; } } } }