public IParseItem Visit(AssignmentItem target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } if (target.Local) { _tree.DefineLocal(target.Names.Select(i => i as NameItem)); } else { foreach (var item in target.Names) { item.Accept(this); } } foreach (var item in target.Expressions) { item.Accept(this); } return(target); }
public IActionResult Delete(AssignmentItem model) { var deleteModel = _db.AssignmentItems.Find(model.Id); _db.Remove(deleteModel); _db.SaveChanges(); return(RedirectToAction("Index")); }
public void List_Success() { var expected = new AssignmentItem( new[] { new NameItem("foo"), new NameItem("bar"), }, new[] { new LiteralItem("cat") }); var actual = new AssignmentItem( new[] { new NameItem("foo"), new NameItem("bar"), }, new[] { new LiteralItem("cat") }); ParseItemEquals.CheckEquals(expected, actual); }
private void AddAssignmentMethod(object input) { Guid assignmentId = Guid.NewGuid(); AssignmentItem assignmentItem = new AssignmentItem(assignmentId, SelectedGroup.Id, SelectedUser.Id); _dbManager.AddAssignment(assignmentItem); GroupsContainer.AddAssigment(assignmentItem); UpdateAssignmentsView(); }
public async Task <IActionResult> Create(AssignmentItem model) { if (ModelState.IsValid) { _db.Add(model); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public void List_FailureValue() { var expected = new AssignmentItem( new[] { new NameItem("foo"), new NameItem("bar"), }, new[] { new LiteralItem("cat") }); var actual = new AssignmentItem( new[] { new NameItem("foo"), new NameItem("baz") }, new[] { new LiteralItem("cat") }); _checkError(".Names[1]", () => ParseItemEquals.CheckEquals(expected, actual)); }
/// <summary> /// Deletes an AssignmentItem /// </summary> public void DeleteItem(AssignmentItem item) { AlertDialog.Builder dialog = new AlertDialog.Builder(Activity) .SetTitle("Delete") .SetMessage("Are you sure you want to delete this item?") .SetPositiveButton("Yes", (sender, e) => { itemViewModel.DeleteAssignmentItemAsync(Assignment, item).ContinueWith(_ => Activity.RunOnUiThread(ReloadItems)); }) .SetNegativeButton("No", (sender, e) => { }); dialog.Show(); }
public ActionResult Assignments(int Id = 0) { int userId = int.Parse(Session["UserId"].ToString()); List <AssignmentItem> assignments = new List <AssignmentItem>(); using (EastWoodEntities db = new EastWoodEntities()) { int studentId = db.Students.Where(w => w.UserId == userId).Select(s => s.StudentId).FirstOrDefault(); if (studentId == 0) { return(Redirect("/")); } List <Assignment> items = new List <Assignment>(); if (Id == 0) { items = db.Assignments .Join( db.Subjects, a => a.SubjectId, s => s.SubjectId, (a, s) => new { Subject = s, Assignment = a } ) .Join( db.Semesters, asSub => asSub.Subject.SemesterId, sem => sem.SemesterId, (asSub, sem) => new { Semester = sem, Assignment = asSub.Assignment } ) .Join( db.StudentCourses.Where(w => w.StudentId == studentId), asSubCourse => asSubCourse.Semester.CourseId, sc => sc.CourseId, (asSubCourse, sc) => new { Assignment = asSubCourse.Assignment } ) .Select(s => s.Assignment) .ToList(); } else { items = db.Assignments.Where(w => w.SubjectId == Id).ToList(); } foreach (var item in items) { AssignmentItem assignment = new AssignmentItem(); assignment.Assignment = item; assignment.Subject = item.Subject; assignment.AssignmentMarks = MarksHelper.GetMarksForAssignment(item.AssignmentId, studentId); assignment.AssignmentGrade = MarksHelper.GetGradeForAssignment(item.AssignmentId, studentId); assignments.Add(assignment); } } ViewBag.SubjectId = Id; return(View(assignments)); }
public void DeleteAssignmentItem() { var assignmentItem = new AssignmentItem(); var saveTask = service.SaveAssignmentItemAsync(assignmentItem, CancellationToken.None); saveTask.Wait(); var deleteTask = service.DeleteAssignmentItemAsync(assignmentItem, CancellationToken.None); deleteTask.Wait(); Assert.That(deleteTask.Result, Is.EqualTo(1)); }
/// <summary> /// Saves an assignment item /// </summary> public Task SaveAssignmentItemAsync(Assignment assignment, AssignmentItem item) { bool newItem = item.Id == 0; return(service .SaveAssignmentItemAsync(item) .ContinueWith(t => { if (newItem) { assignment.TotalItems++; } })); }
public async Task <IActionResult> CreateAssignmentItemAsync(AssignmentItem assignmentItem) { try { await _assignmentItemService.CreateAssignmentItemAsync(assignmentItem); return(Ok()); } catch (BussinessException ex) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Internal server error: {ex.Message}")); } }
public void SaveAssignmentItemInsert() { var assignmentItem = new AssignmentItem(); assignmentItem.ItemId = 1; assignmentItem.AssignmentId = 1; var saveTask = service.SaveAssignmentItemAsync(assignmentItem, CancellationToken.None); saveTask.Wait(); Assert.That(saveTask.Result, Is.EqualTo(1)); }
public void AddAssignment(AssignmentItem assignmentItem) { List <User> foundUserIds = _db.Users.Where(u => u.Id == assignmentItem.UserId).ToList(); List <Group> foundGoupIds = _db.Groups.Where(g => g.Id == assignmentItem.GroupId).ToList(); if (foundUserIds.Any() && foundGoupIds.Any()) { _db.Assignments.Add(new Assignment() { Id = assignmentItem.Id, UserId = assignmentItem.UserId, GroupId = assignmentItem.GroupId }); _db.SaveChanges(); } }
/// <summary> /// List view item click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public async void OnItemClick(object sender, ItemClickEventArgs e) { Item item = e.ClickedItem as Item; if (item != null) { AssignmentItem assignmentItem = new AssignmentItem { AssignmentId = assignmentViewModel.SelectedAssignment.Id, ItemId = item.Id, }; itemViewModel.SaveAssignmentItemCommand.Invoke(assignmentItem); await itemViewModel.LoadAssignmentItemsAsync(assignmentViewModel.SelectedAssignment); itemViewModel.CancelAddItemCommand.Invoke(); } }
public ActionResult Assignments(int Id = 0) { int userId = int.Parse(Session["UserId"].ToString()); List <AssignmentItem> assignments = new List <AssignmentItem>(); using (EastWoodEntities db = new EastWoodEntities()) { Lecturer lecturer = db.Lecturers.Where(w => w.UserId == userId).FirstOrDefault(); List <Assignment> items = new List <Assignment>(); if (lecturer != null && Id == 0) { items = db.Assignments .Join( db.Subjects, a => a.SubjectId, s => s.SubjectId, (a, s) => new { Assignment = a, Subject = s } ) .Where(w => w.Subject.LecturerId == lecturer.LecturerId) .Select(s => s.Assignment) .ToList(); } else { if (Id == 0) { items = db.Assignments.ToList(); } else { items = db.Assignments.Where(w => w.SubjectId == Id).ToList(); } } foreach (var item in items) { AssignmentItem assignment = new AssignmentItem(); assignment.Assignment = item; assignment.Subject = item.Subject; assignments.Add(assignment); } } ViewBag.SubjectId = Id; return(View(assignments)); }
public async Task <IActionResult> Edit(AssignmentItem model) { if (ModelState.IsValid) { var editModel = _db.AssignmentItems.Find(model.Id); editModel.AssignmentName = model.AssignmentName; editModel.IsCompleted = model.IsCompleted; if (editModel.IsCompleted) { await _emailService.SendEmailAsync("*****@*****.**", "test", "Task Was Completed", $"Task {editModel.Id} Was Completed on {DateTime.Now}"); } _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public AssInfoDialog(AssignmentItem ass) { this.InitializeComponent(); Date.Text = ass.Date; Name.Text = ass.Name; Score.Text = ass.Score + "/" + ass.MaximumScore; Weight.Text = ass.Weight; Cata.Text = ass.Category; if (ass.Percentage == null) { Percent.Text = "--"; } else { Percent.Text = ass.Percentage; } }
/// <summary> /// Create a new AssignmentItem /// </summary> /// <returns></returns> public async Task CreateAssignmentItemAsync(AssignmentItem assignmentItem) { await _assignmentItemRepository.InsertAsync(assignmentItem); }
/// <summary> /// Convert an incoming ActivityAttempt into SLK Database records /// </summary> /// <param name="activityAttempt">Microsoft.Education.Services.ActivityAttempt record containing CMI datamodel tracking information</param> /// <exception cref="SLKAssignmentException">Thrown if the Assignment cannot be found or if the Assignment Status will not allow additional attempts</exception> public static void ProcessActivityAttempt(ActivityAttempt activityAttempt) { SLKAssignmentsDataContext db = new SLKAssignmentsDataContext(DBConnection); IQueryable <LearnerAssignmentItem> learnerAssignmentQuery = from p in db.LearnerAssignmentItems where p.GuidId == new Guid(activityAttempt.LearnerAssignmentIdentifier) select p; if (learnerAssignmentQuery.Count() == 0) { throw new SLKAssignmentException("LearnerAssignment was not found"); } LearnerAssignmentItem learnerAssignmentItem = learnerAssignmentQuery.Single <LearnerAssignmentItem>(); if (learnerAssignmentItem.NonELearningStatus == (int)CompletionStatus.Completed || learnerAssignmentItem.IsFinal) { throw new SLKAssignmentException("Cannot modify a completed assignment"); } AssignmentItem assignmentItem = learnerAssignmentItem.AssignmentItem; ActivityPackageItem activityPackageItem = null; if (assignmentItem.ActivityPackageItem == null) { #region Create stub PackageItem and ActivityPackageItem for a newly uploaded Grava Package. #region Obtain the gravaPackageFormat PackageFormat gravaPackageFormat = null; IQueryable <PackageFormat> gravaPackageFormatQuery = from p in db.PackageFormats where p.Name == "Grava" select p; if (gravaPackageFormatQuery.Count() == 0) { gravaPackageFormat = new PackageFormat(); gravaPackageFormat.Name = "Grava"; db.PackageFormats.InsertOnSubmit(gravaPackageFormat); } else { gravaPackageFormat = gravaPackageFormatQuery.Single <PackageFormat>(); } #endregion PackageItem packageItem = new PackageItem(); db.PackageItems.InsertOnSubmit(packageItem); packageItem.PackageFormat1 = gravaPackageFormat; packageItem.Location = "Grava Null Package Location"; packageItem.Manifest = XElement.Parse("<GravaNullManifest />"); activityPackageItem = new ActivityPackageItem(); db.ActivityPackageItems.InsertOnSubmit(activityPackageItem); activityPackageItem.ActivityIdFromManifest = "Grava Null Activity Id"; activityPackageItem.OriginalPlacement = 0; activityPackageItem.Title = "Grava Null Activity Title"; activityPackageItem.PackageItem = packageItem; #endregion } else { activityPackageItem = assignmentItem.ActivityPackageItem; } AttemptItem attempt = new AttemptItem(); db.AttemptItems.InsertOnSubmit(attempt); attempt.UserItem = learnerAssignmentItem.UserItem; attempt.ActivityPackageItem1 = activityPackageItem; // RootActivityPackageItem, designer generated name attempt.PackageItem = activityPackageItem.PackageItem; ActivityAttemptItem activityAttemptItem = new ActivityAttemptItem(); db.ActivityAttemptItems.InsertOnSubmit(activityAttemptItem); activityAttemptItem.AttemptItem = attempt; activityAttemptItem.ActivityPackageItem = activityPackageItem; // We're assuming one Activity per Package so we just set the Package CompletionStatus to the Activity's CompletionStatus attempt.CompletionStatus = (int)activityAttempt.CompletionStatus; activityAttemptItem.CompletionStatus = (int)activityAttempt.CompletionStatus; activityAttemptItem.RawScore = (float)activityAttempt.Score.Raw; activityAttemptItem.MaxScore = (float)activityAttempt.Score.Max; activityAttemptItem.ScaledScore = (float)activityAttempt.Score.Scaled; // Update the LearnerAssignmentItem's NonELearningStatus and FinalPoints with this data so it shows up on the Grading screen learnerAssignmentItem.NonELearningStatus = (int)activityAttempt.CompletionStatus; learnerAssignmentItem.FinalPoints = (float)activityAttempt.Score.Scaled * 100; db.SubmitChanges(); }
/// <summary> /// Called when the item is an assignment item. /// </summary> /// <param name="target">The object that was passed to IParseItem.Visit.</param> /// <returns>The passed target or a modification of it.</returns> /// <exception cref="System.ArgumentNullException">If target is null.</exception> public IParseItem Visit(AssignmentItem target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } ILGenerator gen = compiler.CurrentGenerator; // ILuaValue[] loc = new ILuaValue[{target.Expressions.Count}]; LocalBuilder loc = compiler.CreateArray(typeof(ILuaValue), target.Expressions.Count); // ILuaValue[] names = new ILuaValue[{target.Names.Count}]; LocalBuilder names = compiler.CreateArray(typeof(ILuaValue), target.Names.Count); // have to evaluate the name indexer expressions before // setting the values otherwise the following will fail: // i, t[i] = i+1, 20 for (int i = 0; i < target.Names.Count; i++) { if (target.Names[i] is IndexerItem) { IndexerItem item = (IndexerItem)target.Names[i]; gen.Emit(OpCodes.Ldloc, names); gen.Emit(OpCodes.Ldc_I4, i); item.Expression.Accept(this); gen.Emit(OpCodes.Stelem, typeof(ILuaValue)); } } for (int i = 0; i < target.Expressions.Count; i++) { // loc[{i}] = {exps[i]}; gen.Emit(OpCodes.Ldloc, loc); gen.Emit(OpCodes.Ldc_I4, i); target.Expressions[i].Accept(this); if (i + 1 == target.Expressions.Count && target.IsLastExpressionSingle) { gen.Emit(OpCodes.Callvirt, typeof(ILuaValue).GetMethod(nameof(ILuaValue.Single))); } gen.Emit(OpCodes.Stelem, typeof(ILuaValue)); } // ILuaMultiValue exp = E.Runtime.CreateMultiValue(loc); LocalBuilder exp = compiler.CreateTemporary(typeof(ILuaMultiValue)); gen.Emit(OpCodes.Ldarg_1); gen.Emit(OpCodes.Callvirt, typeof(ILuaEnvironment).GetProperty(nameof(ILuaEnvironment.Runtime)).GetGetMethod()); gen.Emit(OpCodes.Ldloc, loc); gen.Emit(OpCodes.Callvirt, typeof(ILuaRuntime).GetMethod(nameof(ILuaRuntime.CreateMultiValue))); gen.Emit(OpCodes.Stloc, exp); compiler.RemoveTemporary(loc); for (int i = 0; i < target.Names.Count; i++) { AssignValue(target.Names[i], target.Local, !(target.Names[i] is IndexerItem) ? (Action)null : () => { // only called if the target object is an indexer item. // $index = names[{i}]; gen.Emit(OpCodes.Ldloc, names); gen.Emit(OpCodes.Ldc_I4, i); gen.Emit(OpCodes.Ldelem, typeof(ILuaValue)); }, () => { // $value = exp[{i}]; gen.Emit(OpCodes.Ldloc, exp); gen.Emit(OpCodes.Ldc_I4, i); gen.Emit(OpCodes.Callvirt, typeof(ILuaMultiValue).GetMethod("get_Item")); }); } compiler.RemoveTemporary(exp); compiler.RemoveTemporary(names); return(target); }
public async Task <IActionResult> YardKeptDownAssignments([FromBody] DTParameters dtParameters) { var searchBy = dtParameters.Search?.Value; var orderCriteria = string.Empty; var orderAscendingDirection = true; if (dtParameters.Order != null) { // in this example we just default sort on the 1st column try { orderCriteria = dtParameters.Columns[dtParameters.Order[0].Column].Data; orderAscendingDirection = dtParameters.Order[0].Dir.ToString().ToLower() == "asc"; } catch (Exception) { orderCriteria = "Id"; orderAscendingDirection = true; } //orderAscendingDirection = dtParameters.Order[0].Dir.ToString().ToLower() == "asc"; // orderCriteria = "Id"; } else { // if we have an empty search then just order the results by Id ascending orderCriteria = "Id"; orderAscendingDirection = true; } var user = (await _userManager.FindByNameAsync(HttpContext.User.Identity.Name)); //same thing var result = await _context.AssignmentItems .Include(a => a.Assignment) .ThenInclude(a => a.AssignmentSlot) .Include(a => a.CnFProfile) .Include(a => a.Yard) .Where(a => a.Status == 3 && a.YardId == user.YardId) .ToListAsync(); List <AssignmentItem> assignmentItems = new List <AssignmentItem>(); foreach (var item in result) { AssignmentItem tempAssignmentItem = new AssignmentItem { Id = item.Id, Vessel = item.Vessel, AssignmentDate = item.Assignment.Date, ImpReg = item.ImpReg, MLO = item.MLO, ContainerNumber = item.ContainerNumber, Size = item.Size, Height = item.Height, LineNumber = item.LineNumber, Dst = item.Dst, Remarks = item.Remarks, VerifyNumber = item.VerifyNumber, ExitNumber = item.ExitNumber, AssignmentAssignmentSlotAssignmentName = item.Assignment.AssignmentSlot.AssignmentName, CnFProfileName = item.CnFProfile.Name, KeepDownTime = item.KeepDownTime }; assignmentItems.Add(tempAssignmentItem); } if (!string.IsNullOrEmpty(searchBy)) { assignmentItems = assignmentItems.Where(r => r.Vessel != null && r.Vessel.ToUpper().Contains(searchBy.ToUpper()) || r.AssignmentDate != null && r.AssignmentDate.ToString("dd-MM-yyyy").Contains(searchBy.ToString()) || r.KeepDownTime != null && r.KeepDownTime.ToString("dd-MM-yyyy HH:mm").Contains(searchBy.ToString()) || r.ImpReg != null && r.ImpReg.ToUpper().Contains(searchBy.ToUpper()) || r.MLO != null && r.MLO.ToUpper().Contains(searchBy.ToUpper()) || r.ContainerNumber != null && r.ContainerNumber.ToUpper().Contains(searchBy.ToUpper()) || r.LineNumber != null && r.LineNumber.ToUpper().Contains(searchBy.ToUpper()) || r.Remarks != null && r.Remarks.ToUpper().Contains(searchBy.ToUpper()) || r.VerifyNumber != null && r.VerifyNumber.ToUpper().Contains(searchBy.ToUpper()) || r.ExitNumber != null && r.ExitNumber.ToUpper().Contains(searchBy.ToUpper()) || r.AssignmentAssignmentSlotAssignmentName != null && r.AssignmentAssignmentSlotAssignmentName.ToUpper().Contains(searchBy.ToUpper()) || r.CnFProfileName != null && r.CnFProfileName.ToUpper().Contains(searchBy.ToUpper()) || r.Dst != null && r.Dst.ToUpper().Contains(searchBy.ToUpper()) || r.Size.ToString().Contains(searchBy.ToUpper()) || r.Height.ToString().Contains(searchBy.ToUpper()) ).ToList(); } assignmentItems = orderAscendingDirection ? assignmentItems.AsQueryable().OrderByDynamic(orderCriteria, LinqExtensions.Order.Asc).ToList() : assignmentItems.AsQueryable().OrderByDynamic(orderCriteria, LinqExtensions.Order.Desc).ToList(); // now just get the count of items (without the skip and take) - eg how many could be returned with filtering var filteredResultsCount = result.Count(); var totalResultsCount = await _context.AssignmentItems .Include(a => a.Assignment) .ThenInclude(a => a.AssignmentSlot) .Include(a => a.CnFProfile) .Include(a => a.Yard) .Where(a => a.Status == 3 && a.YardId == user.YardId) .CountAsync(); if (dtParameters.Length == -1) { return(Json(new { draw = dtParameters.Draw, recordsTotal = totalResultsCount, recordsFiltered = filteredResultsCount, data = assignmentItems .Skip(dtParameters.Start) .ToList() })); } else { return(Json(new { draw = dtParameters.Draw, recordsTotal = totalResultsCount, recordsFiltered = filteredResultsCount, data = assignmentItems .Skip(dtParameters.Start) .Take(dtParameters.Length) .ToList() })); } }
/// <summary> /// Update an existing AssignmentItem /// </summary> /// <returns></returns> public async Task UpdateAssignmentItemAsync(AssignmentItem assignmentItem) { await _assignmentItemRepository.UpdateAsync(assignmentItem); }
public async Task <IActionResult> LoadTable2([FromBody] DTParameters dtParameters) { var searchBy = dtParameters.Search?.Value; var orderCriteria = string.Empty; var orderAscendingDirection = true; if (dtParameters.Order != null) { try { orderCriteria = dtParameters.Columns[dtParameters.Order[0].Column].Data; orderAscendingDirection = dtParameters.Order[0].Dir.ToString().ToLower() == "asc"; } catch (Exception) { orderCriteria = "Id"; orderAscendingDirection = false; } } else { orderCriteria = "Id"; orderAscendingDirection = false; } //here var id = (await _userManager.FindByNameAsync(HttpContext.User.Identity.Name)).Id; var result = await _context.AssignmentItems .Include(a => a.Assignment) .ThenInclude(a => a.AssignmentSlot) .Include(a => a.CnFProfile) .Include(a => a.Yard) .Where(a => a.Status >= 1 && a.CnFProfile.ApplicationUserId == id && a.YardId == 2).ToListAsync(); //here List <AssignmentItem> AssignmentItems = new List <AssignmentItem>(); //here foreach (var item in result) { AssignmentItem tempAssignmentItem = new AssignmentItem { Id = item.Id, Vessel = item.Vessel, ImpReg = item.ImpReg, MLO = item.MLO, ContainerNumber = item.ContainerNumber, Size = item.Size, Height = item.Height, LineNumber = item.LineNumber, Dst = item.Dst, Remarks = item.Remarks, VerifyNumber = item.VerifyNumber, ExitNumber = item.ExitNumber, EstimatedTruckQty = item.EstimatedTruckQty, Status = item.Status, AssignmentDate = item.Assignment.Date, AssignmentAssignmentSlotAssignmentName = item.Assignment.AssignmentSlot.AssignmentName, YardName = item.Yard.Name, }; AssignmentItems.Add(tempAssignmentItem); } //here if (!string.IsNullOrEmpty(searchBy)) { AssignmentItems = AssignmentItems.Where(r => r.Vessel != null && r.Vessel.ToUpper().Contains(searchBy.ToUpper()) || r.ImpReg != null && r.ImpReg.ToUpper().Contains(searchBy.ToUpper()) || r.MLO != null && r.MLO.ToUpper().Contains(searchBy.ToUpper()) || r.ContainerNumber != null && r.ContainerNumber.ToUpper().Contains(searchBy.ToUpper()) || r.LineNumber != null && r.LineNumber.ToUpper().Contains(searchBy.ToUpper()) || r.Dst != null && r.Dst.ToUpper().Contains(searchBy.ToUpper()) || r.Remarks != null && r.Remarks.ToUpper().Contains(searchBy.ToUpper()) || r.VerifyNumber != null && r.VerifyNumber.ToUpper().Contains(searchBy.ToUpper()) || r.ExitNumber != null && r.ExitNumber.ToUpper().Contains(searchBy.ToUpper()) || r.Size.ToString().Contains(searchBy.ToUpper()) || r.Height.ToString().Contains(searchBy.ToUpper()) || r.EstimatedTruckQty.ToString().Contains(searchBy.ToUpper()) || r.AssignmentDate != null && r.AssignmentDate.ToString("dd-MM-yyyy").Contains(searchBy.ToString()) || r.AssignmentAssignmentSlotAssignmentName != null && r.AssignmentAssignmentSlotAssignmentName.ToUpper().Contains(searchBy.ToUpper()) || r.YardName != null && r.YardName.ToUpper().Contains(searchBy.ToUpper()) ).ToList(); } //here AssignmentItems = orderAscendingDirection ? AssignmentItems.AsQueryable().OrderByDynamic(orderCriteria, LinqExtensions.Order.Asc).ToList() : AssignmentItems.AsQueryable().OrderByDynamic(orderCriteria, LinqExtensions.Order.Desc).ToList(); var filteredResultsCount = result.Count(); //here var totalResultsCount = await _context.AssignmentItems .Include(a => a.Assignment) .ThenInclude(a => a.AssignmentSlot) .Include(a => a.CnFProfile) .Include(a => a.Yard) .Where(a => a.Status >= 1 && a.CnFProfile.ApplicationUserId == id && a.YardId == 2).CountAsync(); if (dtParameters.Length == -1) { return(Json(new { draw = dtParameters.Draw, recordsTotal = totalResultsCount, recordsFiltered = filteredResultsCount, //here data = AssignmentItems .Skip(dtParameters.Start) .ToList() })); } else { return(Json(new { draw = dtParameters.Draw, recordsTotal = totalResultsCount, recordsFiltered = filteredResultsCount, //here data = AssignmentItems .Skip(dtParameters.Start) .Take(dtParameters.Length) .ToList() })); } }
/// <summary> /// Sets the current assignment item /// </summary> public void SetItem(AssignmentItem item) { label.Text = string.Format("{0} {1}", item.Name, item.Number); }
/// <summary> /// Delete an existing AssignmentItem /// </summary> /// <returns></returns> public async Task DeleteAssignmentItemAsync(AssignmentItem assignmentItem) { await _assignmentItemRepository.DeleteAsync(assignmentItem); }
public Task <int> DeleteAssignmentItemAsync(AssignmentItem assignmentItem, CancellationToken cancellationToken) { return(Task.Factory.StartNew(() => 1)); }
public void GenralParse() { PlainParser target = new PlainParser(); TextElementEnumerator input1 = StringInfo.GetTextElementEnumerator( @"local a = 12 t = { [34]= function() print(i) end } function Some(a, ...) a, b, c = ... for i= 12, 23 do print(i) end end" ); IParseItem actual; actual = target.Parse(new Tokenizer(input1, null), null, null); // check the main block BlockItem block = actual as BlockItem; Assert.IsInstanceOf <BlockItem>(actual); Assert.IsNotNull(block.Children); Assert.AreEqual(3, block.Children.Count, "Block.Children.Count"); ValidateDebug(block.Debug, "Block", "local a = 12 t = { [ 34 ] = function ( ) print ( i ) end } function Some ( a , ... ) a , b , c = ... for i = 12 , 23 do print ( i ) end end", 1, 1, 8, 4); // check the return statement of the main block { ReturnItem ret = block.Return; Assert.IsInstanceOf <ReturnItem>(block.Return); ValidateDebug(ret.Debug, "Block.Return", null, 0, 0, 0, 0); Assert.IsNotNull(ret.Expressions); Assert.AreEqual(0, ret.Expressions.Count); } // local a = 12 { AssignmentItem init = block.Children[0] as AssignmentItem; Assert.IsNotNull(init, "Block.Children[0]"); Assert.AreEqual(true, init.Local); ValidateDebug(init.Debug, "Block.Children[0]", "local a = 12", 1, 1, 1, 13); // check the names { Assert.IsNotNull(init.Names, "Block.Children[0].Names"); Assert.AreEqual(1, init.Names.Count, "Block.Children[0].Names.Count"); NameItem name = init.Names[0] as NameItem; Assert.IsNotNull(name, "Block.Children[0].Names[0]"); Assert.AreEqual("a", name.Name, "Block.Children[0].Names[0].Name"); ValidateDebug(name.Debug, "Block.Children[0].Names[0]", "a", 1, 7, 1, 8); } // check the expressions { Assert.IsNotNull(init.Expressions, "Block.Children[0].Expressions"); Assert.AreEqual(1, init.Expressions.Count, "Block.Children[0].Expressions.Count"); LiteralItem literal = init.Expressions[0] as LiteralItem; Assert.IsNotNull(literal, "Block.Children[0].Expressions[0]"); Assert.AreEqual(12.0, literal.Value, "Block.Children[0].Expressions[0].Value"); ValidateDebug(literal.Debug, "Block.Children[0].Expressions[0]", "12", 1, 11, 1, 13); } } // t = { [34]= function() print(i) end } { AssignmentItem init = block.Children[1] as AssignmentItem; Assert.IsNotNull(init, "Block.Children[1]"); Assert.AreEqual(false, init.Local); ValidateDebug(init.Debug, "Block.Children[1]", "t = { [ 34 ] = function ( ) print ( i ) end }", 2, 1, 2, 38); // check the names { Assert.IsNotNull(init.Names, "Block.Children[1].Names"); Assert.AreEqual(1, init.Names.Count, "Block.Children[1].Names.Count"); NameItem name = init.Names[0] as NameItem; Assert.IsNotNull(name, "Block.Children[1].Names[0]"); Assert.AreEqual("t", name.Name, "Block.Children[1].Names[0].Name"); ValidateDebug(name.Debug, "Block.Children[1].Names[0]", "t", 2, 1, 2, 2); } // check the expressions { Assert.IsNotNull(init.Expressions, "Block.Children[1].Expressions"); Assert.AreEqual(1, init.Expressions.Count, "Block.Children[1].Expressions.Count"); TableItem table = init.Expressions[0] as TableItem; Assert.IsNotNull(table, "Block.Children[1].Expressions[0]"); ValidateDebug(table.Debug, "Block.Children[1].Expressions[0]", "{ [ 34 ] = function ( ) print ( i ) end }", 2, 5, 2, 38); Assert.IsNotNull(table.Fields, "Block.Children[1].Expressions[0].Fields"); Assert.AreEqual(1, table.Fields.Count, "Block.Children[1].Expressions[0].Fields.Count"); var field = table.Fields[0]; { LiteralItem literal = field.Key as LiteralItem; Assert.IsNotNull(literal, "Block.Children[1].Expressions[0].Fields[0].Item1"); Assert.AreEqual(34.0, literal.Value, "Block.Children[1].Expressions[0].Fields[0].Item1.Value"); ValidateDebug(literal.Debug, "Block.Children[1].Expressions[0].Fields[0].Item1", "34", 2, 8, 2, 10); } { FuncDefItem func = field.Value as FuncDefItem; Assert.IsNotNull(func, "Block.Children[1].Expressions[0].Fields[0].Item2"); Assert.IsNull(func.InstanceName, "Block.Children[1].Expressions[0].Fields[0].Item2.InstanceName"); Assert.IsNull(func.Prefix, "Block.Children[1].Expressions[0].Fields[0].Item2.Prefix"); Assert.AreEqual(false, func.Local, "Block.Children[1].Expressions[0].Fields[0].Item2.Local"); Assert.IsNull(func.FunctionInformation, "Block.Children[1].Expressions[0].Fields[0].Item2.FunctionInformation"); ValidateDebug(func.Debug, "Block.Children[1].Expressions[0].Fields[0].Item2", "function ( ) print ( i ) end", 2, 13, 2, 36); // validate the block { BlockItem funcBlock = func.Block; Assert.IsNotNull(funcBlock, "Block.Children[1].Expressions[0].Fields[0].Item2.Block"); ValidateDebug(funcBlock.Debug, "Block.Children[1].Expressions[0].Fields[0].Item2.Block", "print ( i )", 2, 24, 2, 32); // validate the return { ReturnItem ret = funcBlock.Return; Assert.IsNotNull(ret, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Return"); ValidateDebug(ret.Debug, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Return", null, 0, 0, 0, 0); Assert.IsNotNull(ret.Expressions, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Return.Expressions"); Assert.AreEqual(0, ret.Expressions.Count, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Return.Expressions.Count"); } // validate the statement { Assert.IsNotNull(funcBlock.Children, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children"); Assert.AreEqual(1, funcBlock.Children.Count, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children.Count"); // print ( i ) { FuncCallItem call = funcBlock.Children[0] as FuncCallItem; Assert.IsNotNull(call, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0]"); Assert.AreEqual(true, call.Statement, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Statement"); Assert.IsNull(call.InstanceName, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].InstanceName"); ValidateDebug(call.Debug, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0]", "print ( i )", 2, 24, 2, 32); // validate the prefix { NameItem name = call.Prefix as NameItem; Assert.IsNotNull(call.Prefix, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Prefix"); Assert.AreEqual("print", name.Name, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Prefix.Name"); ValidateDebug(name.Debug, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Prefix.Name", "print", 2, 24, 2, 29); } // validate the arguments { Assert.IsNotNull(call.Arguments, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Arguments"); Assert.AreEqual(1, call.Arguments.Count, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Arguments.Count"); NameItem name = call.Arguments[0].Expression as NameItem; Assert.IsNotNull(name, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Arguments[0]"); Assert.AreEqual("i", name.Name, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Arguments[0].Name"); ValidateDebug(name.Debug, "Block.Children[1].Expressions[0].Fields[0].Item2.Block.Children[0].Arguments[0]", "i", 2, 30, 2, 31); } } } } } } } // function Some(a, ...) { FuncDefItem func = block.Children[2] as FuncDefItem; Assert.IsNotNull(func, "Block.Children[2]"); Assert.AreEqual(false, func.Local, "Block.Children[2].Local"); Assert.IsNull(func.InstanceName, "Block.Children[2].InstanceName"); ValidateDebug(func.Debug, "Block.Children[2]", "function Some ( a , ... ) a , b , c = ... for i = 12 , 23 do print ( i ) end end", 3, 1, 8, 4); // validate the block { BlockItem someBlock = func.Block; ValidateDebug(someBlock.Debug, "Block.Children[2].Block", "a , b , c = ... for i = 12 , 23 do print ( i ) end", 4, 5, 7, 8); // validate the return { ReturnItem ret = someBlock.Return; Assert.IsNotNull(ret, "Block.Children[2].Block.Return"); ValidateDebug(ret.Debug, "Block.Children[2].Block.Return", null, 0, 0, 0, 0); Assert.IsNotNull(ret.Expressions, "Block.Children[2].Block.Return.Expressions"); Assert.AreEqual(0, ret.Expressions.Count, "Block.Children[2].Block.Return.Expressions.Count"); } // check the children { Assert.IsNotNull(someBlock.Children, "Block.Children[2].Block.Children"); Assert.AreEqual(2, someBlock.Children.Count, "Block.Children[2].Block.Children.Count"); // a , b , c = ... { AssignmentItem varInit = someBlock.Children[0] as AssignmentItem; Assert.IsNotNull(varInit, "Block.Children[2].Block.Children[0]"); Assert.AreEqual(false, varInit.Local, "Block.Children[2].Block.Children[0].Local"); ValidateDebug(varInit.Debug, "Block.Children[2].Block.Children[0]", "a , b , c = ...", 4, 5, 4, 18); // validate the names { Assert.IsNotNull(varInit.Names, "Block.Children[2].Block.Children[0].Names"); Assert.AreEqual(3, varInit.Names.Count, "Block.Children[2].Block.Children[0].Names.Count"); NameItem name = varInit.Names[0] as NameItem; Assert.IsNotNull(name, "Block.Children[2].Block.Children[0].Names[0]"); Assert.AreEqual(name.Name, "a", "Block.Children[2].Block.Children[0].Names[0].Name"); ValidateDebug(name.Debug, "Block.Children[2].Block.Children[0].Names[0]", "a", 4, 5, 4, 6); name = varInit.Names[1] as NameItem; Assert.IsNotNull(name, "Block.Children[2].Block.Children[0].Names[1]"); Assert.AreEqual(name.Name, "b", "Block.Children[2].Block.Children[0].Names[1].Name"); ValidateDebug(name.Debug, "Block.Children[2].Block.Children[0].Names[1]", "b", 4, 8, 4, 9); name = varInit.Names[2] as NameItem; Assert.IsNotNull(name, "Block.Children[2].Block.Children[0].Names[2]"); Assert.AreEqual(name.Name, "c", "Block.Children[2].Block.Children[0].Names[2].Name"); ValidateDebug(name.Debug, "Block.Children[2].Block.Children[0].Names[2]", "c", 4, 11, 4, 12); } // validate the expressions { Assert.IsNotNull(varInit.Expressions, "Block.Children[2].Block.Children[0].Expressions"); Assert.AreEqual(1, varInit.Expressions.Count, "Block.Children[2].Block.Children[0].Expressions.Count"); NameItem name = varInit.Expressions[0] as NameItem; Assert.IsNotNull(name, "Block.Children[2].Block.Children[0].Expressions[0]"); Assert.AreEqual(name.Name, "...", "Block.Children[2].Block.Children[0].Expressions[0].Name"); ValidateDebug(name.Debug, "Block.Children[2].Block.Children[0].Expressions[0]", "...", 4, 15, 4, 18); } } // for i= 12, 23 do print ( i ) end { ForNumItem forLoop = someBlock.Children[1] as ForNumItem; Assert.IsNotNull(forLoop, "Block.Children[2].Block.Children[1]"); ValidateDebug(forLoop.Debug, "Block.Children[2].Block.Children[1]", "for i = 12 , 23 do print ( i ) end", 5, 5, 7, 8); // validate the name { NameItem name = forLoop.Name; Assert.IsNotNull(name, "Block.Children[2].Block.Children[1].Name"); ValidateDebug(name.Debug, "Block.Children[2].Block.Children[1].Name", "i", 5, 9, 5, 10); Assert.AreEqual(name.Name, "i", "Block.Children[2].Block.Children[1].Name.Name"); } // validate the start { LiteralItem lit = forLoop.Start as LiteralItem; Assert.IsNotNull(lit, "Block.Children[2].Block.Children[1].Start"); Assert.AreEqual(12.0, lit.Value, "Block.Children[2].Block.Children[1].Start.Value"); ValidateDebug(lit.Debug, "Block.Children[2].Block.Children[1].Start", "12", 5, 12, 5, 14); } // validate the limit { LiteralItem lit = forLoop.Limit as LiteralItem; Assert.IsNotNull(lit, "Block.Children[2].Block.Children[1].Limit"); Assert.AreEqual(23.0, lit.Value, "Block.Children[2].Block.Children[1].Limit.Value"); ValidateDebug(lit.Debug, "Block.Children[2].Block.Children[1].Limit", "23", 5, 16, 5, 18); } // validate the step { Assert.IsNull(forLoop.Step, "Block.Children[2].Block.Children[1].Step"); } // validate the block { BlockItem forBlock = forLoop.Block; ValidateDebug(forBlock.Debug, "Block.Children[2].Block.Children[1].Block", "print ( i )", 6, 9, 6, 17); Assert.IsNull(forBlock.Return, "Block.Children[2].Block.Children[1].Block.Return"); // validate the statement { Assert.IsNotNull(forBlock.Children, "Block.Children[2].Block.Children[1].Block.Children"); Assert.AreEqual(1, forBlock.Children.Count, "Block.Children[2].Block.Children[1].Block.Children.Count"); // print ( i ) { FuncCallItem call = forBlock.Children[0] as FuncCallItem; Assert.IsNotNull(call, "Block.Children[2].Block.Children[1].Block.Children[0]"); Assert.AreEqual(true, call.Statement, "Block.Children[2].Block.Children[1].Block.Children[0].Statement"); Assert.IsNull(call.InstanceName, "Block.Children[2].Block.Children[1].Block.Children[0].InstanceName"); ValidateDebug(call.Debug, "Block.Children[2].Block.Children[1].Block.Children[0]", "print ( i )", 6, 9, 6, 17); // validate the prefix { NameItem name = call.Prefix as NameItem; Assert.IsNotNull(call.Prefix, "Block.Children[2].Block.Children[1].Block.Children[0].Prefix"); Assert.AreEqual("print", name.Name, "Block.Children[2].Block.Children[1].Block.Children[0].Prefix.Name"); ValidateDebug(name.Debug, "Block.Children[2].Block.Children[1].Block.Children[0].Prefix.Name", "print", 6, 9, 6, 14); } // validate the arguments { Assert.IsNotNull(call.Arguments, "Block.Children[2].Block.Children[1].Block.Children[0].Arguments"); Assert.AreEqual(1, call.Arguments.Count, "Block.Children[2].Block.Children[1].Block.Children[0].Arguments.Count"); NameItem name = call.Arguments[0].Expression as NameItem; Assert.IsNotNull(name, "Block.Children[2].Block.Children[1].Block.Children[0].Arguments[0]"); Assert.AreEqual("i", name.Name, "Block.Children[2].Block.Children[1].Block.Children[0].Arguments[0].Name"); ValidateDebug(name.Debug, "Block.Children[2].Block.Children[1].Block.Children[0].Arguments[0]", "i", 6, 15, 6, 16); } } } } } } } } }
/// <summary> /// Deletes an assignment item /// </summary> public Task DeleteAssignmentItemAsync(Assignment assignment, AssignmentItem item) { return(service .DeleteAssignmentItemAsync(item) .ContinueWith(t => assignment.TotalItems--)); }
/// <summary> /// Sets the current assignment item /// </summary> public void SetItem(AssignmentItem item) { label.TextColor = Theme.LabelColor; label.Text = item.Name + " " + item.Number; }
/// <summary> /// Sets the current assignment item /// </summary> public void SetItem(AssignmentItem item) { label.Text = item.Name + " " + item.Number; }