public void GetJobsForUserWithReadPermissionReturnsJobsTheUserIsAuthorizedFor() { Mock.Arrange(() => CurrentUserDataProvider.GetIdentity(TENANT_ID)) .Returns(new Identity { Permissions = new List <String> { JOB_READ_PERMISSION }, Username = CURRENT_USER_ID, Tid = TENANT_ID }) .MustBeCalled(); Mock.Arrange(() => CurrentUserDataProvider.GetEntitiesForUser(Arg.IsAny <DbSet <Job> >(), CURRENT_USER_ID, TENANT_ID)) .ReturnsCollection(CreateSampleJobDbSet().ToList()) .MustBeCalled(); Mock.Arrange(() => _lifeCycleContext.Jobs) .IgnoreInstance() .ReturnsCollection(CreateSampleJobDbSet()) .MustBeCalled(); var actionResult = _jobsController.GetJobs( CreateODataQueryOptions("http://localhost/api/Core.svc/Jobs")) .Result; Assert.IsTrue(actionResult.GetType() == typeof(OkNegotiatedContentResult <IEnumerable <Job> >)); var response = actionResult as OkNegotiatedContentResult <IEnumerable <Job> >; Assert.IsNotNull(response); Assert.AreEqual(2, response.Content.Count()); Mock.Assert(() => CurrentUserDataProvider.GetIdentity(TENANT_ID)); Mock.Assert(() => CurrentUserDataProvider.GetEntitiesForUser(Arg.IsAny <DbSet <Job> >(), CURRENT_USER_ID, TENANT_ID)); Mock.Assert(_lifeCycleContext); }
protected void gridJobs_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { try { JobsController jcont = new JobsController(); gridJobs.DataSource = jcont.GetJobs().Where(o => o.JobsMainID != PTSFromGreeceID && o.JobsMainID != PTSToGreeceID).OrderBy(o => o.Name); } catch (Exception) { } }
protected void gridMain_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { int recSkip = gridMain.MasterTableView.CurrentPageIndex * gridMain.MasterTableView.PageSize; int recTake = gridMain.MasterTableView.PageSize; string recFilter = gridMain.MasterTableView.FilterExpression; try { JobsController cont = new JobsController(); gridMain.VirtualItemCount = cont.CountJobs(recFilter); gridMain.DataSource = cont.GetJobs(recSkip, recTake, recFilter); } catch (Exception) { } }
private void Jobs_Load(object sender, EventArgs e) { InitListView(); jobs = jobsController.GetJobs(carID, page, shownItems); UpdateListView(); }
protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e) { /* * if (e.Item.OwnerTableView.Name == "Master") { * if (e.Item is GridDataItem) { * GridDataItem item = (GridDataItem)e.Item; * if (item.OwnerTableView.DataSource != null) { * TaskB curTask = (item.OwnerTableView.DataSource as List<TaskB>)[item.DataSetIndex]; * TableCell curCell = item["RegNo"]; * string curComments = curTask.Comments; * string curTooltip = "<span><span class=\"tooltip tooltip-effect-4\"><span class=\"tooltip-item\">"; * curTooltip += curCell.Text; * curTooltip += "</span><span class=\"tooltip-content clearfix\"><span class=\"tooltip-text\"><strong>Παρατηρήσεις:</strong><br/>"; * curTooltip += curComments; * curTooltip += "</span></span></span></span>"; * if (!string.IsNullOrWhiteSpace(curComments)) { curCell.Text = curTooltip; } * System.Drawing.Color hColor = System.Drawing.Color.FromArgb(0, 0, 0); * if (curTask.IsLocked == true) { hColor = System.Drawing.Color.FromArgb(200, 0, 0); } * item["ID"].ForeColor = hColor; * item["RegNo"].ForeColor = hColor; * item["OrderDate"].ForeColor = hColor; * item["CustomerID"].ForeColor = hColor; * item["JobsID"].ForeColor = hColor; * item["DateTimeStartActual"].ForeColor = hColor; * if (curTask.IsLocked == true && loggedUser.UserGroupID != 1) { * item["EditCommandColumn"].Controls[0].Visible = false; * item["btnDelete"].Controls[0].Visible = false; * item["ExapandColumn"].Controls[0].Visible = false; * } * } * } * } */ if (e.Item.OwnerTableView.Name == "Master") { if (e.Item is GridFilteringItem) { GridFilteringItem filterItem = (GridFilteringItem)e.Item; RadDropDownList clist = (RadDropDownList)filterItem.FindControl("ddlCustomersFilter"); RadDropDownList jlist = (RadDropDownList)filterItem.FindControl("ddlJobsFilter"); RadDropDownList plist = (RadDropDownList)filterItem.FindControl("ddlPositionsFilter"); try { CustomersController ccont = new CustomersController(); clist.DataSource = ccont.GetCustomers(); clist.DataTextField = "NameGR"; clist.DataValueField = "ID"; clist.DataBind(); clist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); JobsController jcont = new JobsController(); jlist.DataSource = jcont.GetJobs(); jlist.DataTextField = "Name"; jlist.DataValueField = "ID"; jlist.DataBind(); jlist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); DistancesController dcont = new DistancesController(); plist.DataSource = dcont.GetDistances(); plist.DataTextField = "Description"; plist.DataValueField = "ID"; plist.DataBind(); plist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0")); } catch (Exception) { } } if (e.Item is GridDataItem) { GridDataItem item = e.Item as GridDataItem; ImageButton editButton = item["EditCommandColumn"].Controls[0] as ImageButton; editButton.ImageUrl = "~/Images/mag.png"; } } }