private Activity CreateMoveCardActivity(Card card, RedfernDb db, BoardColumn targetColumn = null) { // create an activity Activity activity = db.Activities.Create(); activity.ActivityDate = DateTime.UtcNow; activity.SetVerb("moved"); activity.SetActor(db.Context.ClientUserName, db.Context.ClientUserFullName); activity.SetObject("card", card.CardId.ToString(), card.Title, String.Format(@"/board/{0}/card/{1}", card.BoardId, card.CardId)); activity.SetSource("column", card.ColumnId.ToString(), card.Column.Name, ""); activity.SetContext("board", card.BoardId.ToString(), card.Board.Name, String.Format(@"/board/{0}", card.BoardId)); if (targetColumn != null) { activity.SetTarget("column", targetColumn.ColumnId.ToString(), targetColumn.Name, ""); activity.SetDescription("{actor} moved card {object} from {source} to {target} in board {context}."); } else { activity.SetDescription("{actorlink} moved card {object} in board {context}."); } activity = db.Activities.Add(activity); return(activity); }
private Board FindTargetBoard(List <Board> targetBoards, Dictionary <string, List <BoardColumn> > targetBoardColumnsMappedToBoards, List <BoardColumn> sourceBoardColumns) { BoardColumn sourceColumn = sourceBoardColumns[0]; foreach (string sourceWitName in sourceColumn.stateMappings.Keys) { string targetWitName = sourceWitName; if (Engine.TypeDefinitionMaps.Items.ContainsKey(sourceWitName)) { targetWitName = Engine.TypeDefinitionMaps.Items[sourceWitName].Map(); } foreach (var board in targetBoards) { var mapping = targetBoardColumnsMappedToBoards[board.id]; if (mapping.Any(m => m.stateMappings.ContainsKey(targetWitName))) { return(board); } } } return(null); }
public CommandResult <Card> Execute(RedfernDb db) { Card card = db.Cards.Find(this.CardId); BoardColumn archivedColumn = db.BoardColumns.Where(c => c.Name == "Archived" && c.BoardId == card.BoardId).SingleOrDefault(); if (archivedColumn == null) { archivedColumn = db.BoardColumns.Create(); archivedColumn.BoardId = card.BoardId; archivedColumn.Name = "Archived"; archivedColumn.Sequence = card.Board.Columns.Count + 1; archivedColumn.Hidden = true; archivedColumn = db.BoardColumns.Add(archivedColumn); db.SaveChanges(); } card.ColumnId = archivedColumn.ColumnId; card.Sequence = archivedColumn.Cards.Count + 1; card.ArchivedDate = DateTime.UtcNow; db.SaveChanges(); Activity activity = db.Activities.Create(); activity.ActivityDate = DateTime.UtcNow; activity.SetVerb("archived"); activity.SetActor(db.Context.ClientUserName, db.Context.ClientUserFullName); activity.SetObject("card", card.CardId.ToString(), card.Title, String.Format(@"/board/{0}/card/{1}", card.BoardId, card.CardId)); activity.SetContext("board", card.BoardId.ToString(), card.Board.Name, String.Format(@"/board/{0}", card.BoardId)); activity.SetDescription("{actorlink} archived card {objectlink} in {contextlink}"); activity = db.Activities.Add(activity); db.SaveChanges(); return(this.CommandResult <Card>(card, db, activity)); }
public async Task <IHttpActionResult> Post(string boardSlug, BoardColumn boardColumn) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await mediator.Send(new CreateBoardColumnCommand { BoardSlug = boardSlug, BoardColumn = boardColumn }); if (result == null) { return(NotFound()); } hyperMediaFactory.Apply(result); return(Created(hyperMediaFactory.GetLink(result, Link.SELF), result)); } catch (CreateBoardColumnCommandSlugExistsException) { return(Conflict()); } catch (BoardNotFoundException) { return(NotFound()); } }
private List <BoardColumn> BuildBoardColumns(List <BoardColumn> sourceBoardColumns, Board targetBoard, Dictionary <string, List <BoardColumn> > targetBoardColumnsMappedToBoards, List <_EngineV1.Containers.IFieldMap> fieldValueMappings) { List <BoardColumn> newColumns = new List <BoardColumn>(); BoardColumn sourceIncomingColumn = sourceBoardColumns.Find(c => c.columnType.Equals("incoming")); BoardColumn targetIncomingColumn = targetBoardColumnsMappedToBoards[targetBoard.id].Find(c => c.columnType.Equals("incoming")); BoardColumn templateTargetIncomingColumn = targetBoardColumnsMappedToBoards[targetBoard.id].Find(c => c.columnType.Equals("incoming")); BoardColumn templateTargetInProgressColumn = targetBoardColumnsMappedToBoards[targetBoard.id].Find(c => c.columnType.Equals("inProgress")); BoardColumn templateTargetOutgoingColumn = targetBoardColumnsMappedToBoards[targetBoard.id].Find(c => c.columnType.Equals("outgoing")); var column = MapExistingBoardColumnProperties(targetBoardColumnsMappedToBoards[targetBoard.id], sourceIncomingColumn, targetIncomingColumn, fieldValueMappings, templateTargetIncomingColumn.stateMappings); newColumns.Add(column); foreach (var inprogressColumn in sourceBoardColumns.Where(c => c.columnType.Equals("inProgress"))) { BoardColumn newInProgressColumn = new BoardColumn(); column = MapExistingBoardColumnProperties(targetBoardColumnsMappedToBoards[targetBoard.id], inprogressColumn, newInProgressColumn, fieldValueMappings, templateTargetInProgressColumn.stateMappings); newColumns.Add(column); } BoardColumn sourceOutgoingColumn = sourceBoardColumns.Find(c => c.columnType.Equals("outgoing")); BoardColumn targetOutgoingColumn = targetBoardColumnsMappedToBoards[targetBoard.id].Find(c => c.columnType.Equals("outgoing")); column = MapExistingBoardColumnProperties(targetBoardColumnsMappedToBoards[targetBoard.id], sourceOutgoingColumn, targetOutgoingColumn, fieldValueMappings, templateTargetOutgoingColumn.stateMappings); newColumns.Add(column); return(newColumns); }
public CommandResult <bool> Execute(RedfernDb db) { BoardColumn column = db.BoardColumns.Find(this.ColumnId); try { Activity activity = db.Activities.Create(); activity.ActivityDate = DateTime.UtcNow; activity.SetVerb("deleted"); activity.SetActor(db.Context.ClientUserName, db.Context.ClientUserFullName); activity.SetObject("column", column.ColumnId.ToString(), column.Name, ""); activity.SetContext("board", column.BoardId.ToString(), column.Board.Name, String.Format(@"/board/{0}", column.BoardId)); activity.SetDescription("{actorlink} deleted column {object} in {context}"); activity = db.Activities.Add(activity); db.SaveChanges(); db.BoardColumns.Remove(column); db.SaveChanges(); return(this.CommandResult <bool>(true, db, activity)); } catch { return(this.CommandResult <bool>(false, db)); } }
public void ActivateSort() { trelloBoardManager.ActivateResort(); SetUpSorter(); for (int i = 0; i < listSortModifiers.Length; i++) { listSortModifiers[i].ActivateSortMode(); listSortModifiers[i].meshRenderer.material = sortMaterials[i]; BoardColumnSortModifier columnSortModifier = listSortModifiers[i]; BoardColumn boardColumn = columnSortModifier.boardColumn; boardColumn.dictationNoteColumn.SetActive(false); string listId = boardColumn.list.id; listIdsOfColumns[i] = listId; NoteSortModifier[] noteSortModifiersOfList = boardColumn.GetComponentsInChildren <NoteSortModifier>(); for (int j = 0; j < noteSortModifiersOfList.Length; j++) { NoteSortModifier noteSortModifier = noteSortModifiersOfList[j]; noteSortModifier.enabled = true; if (defaultCellMaterial == null) { defaultCellMaterial = noteSortModifier.meshRenderer.material; } noteSortModifiers.Add(noteSortModifier); noteSortModifier.sorter = this; cardIdWithListId.Add(noteSortModifier.note.cardId, listId); noteSortModifier.meshRenderer.material = sortMaterials[i]; } } SetActiveColumn(0); }
public void GetBitColumn_ShouldReturnAccurateColumn_GivenFullColumn() { var boardColumn = new BoardColumn(0, 0, null, null, null); boardColumn.SetSpace(DiscColor.Black); boardColumn.SetSpace(DiscColor.Black); boardColumn.SetSpace(DiscColor.Black); boardColumn.SetSpace(DiscColor.Red); boardColumn.SetSpace(DiscColor.Red); boardColumn.SetSpace(DiscColor.Red); var bitColumn = boardColumn.GetBitColumn(); Assert.IsTrue(BitBoardHelpers.CheckSingleBit(bitColumn.BlackDiscs, 0)); Assert.IsTrue(BitBoardHelpers.CheckSingleBit(bitColumn.BlackDiscs, 1)); Assert.IsTrue(BitBoardHelpers.CheckSingleBit(bitColumn.BlackDiscs, 2)); Assert.IsFalse(BitBoardHelpers.CheckSingleBit(bitColumn.BlackDiscs, 3)); Assert.IsFalse(BitBoardHelpers.CheckSingleBit(bitColumn.BlackDiscs, 4)); Assert.IsFalse(BitBoardHelpers.CheckSingleBit(bitColumn.BlackDiscs, 5)); Assert.IsFalse(BitBoardHelpers.CheckSingleBit(bitColumn.RedDiscs, 0)); Assert.IsFalse(BitBoardHelpers.CheckSingleBit(bitColumn.RedDiscs, 1)); Assert.IsFalse(BitBoardHelpers.CheckSingleBit(bitColumn.RedDiscs, 2)); Assert.IsTrue(BitBoardHelpers.CheckSingleBit(bitColumn.RedDiscs, 3)); Assert.IsTrue(BitBoardHelpers.CheckSingleBit(bitColumn.RedDiscs, 4)); Assert.IsTrue(BitBoardHelpers.CheckSingleBit(bitColumn.RedDiscs, 5)); }
public async Task <IActionResult> Edit(int id, [Bind("BoardColumnId,Title,BoardId")] BoardColumn boardColumn) { if (id != boardColumn.BoardColumnId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(boardColumn); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BoardColumnExists(boardColumn.BoardColumnId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BoardId"] = new SelectList(_context.Boards, "BoardId", "BoardId", boardColumn.BoardId); return(View(boardColumn)); }
public ActionResult <string> DeleteColumn() { var output = ""; using (StreamReader reader = new StreamReader(Request.Body)) { output = reader.ReadToEnd(); } RequestData jsonData = JsonConvert.DeserializeObject <RequestData>(output); BoardColumn column = _context.BoardColumns.FirstOrDefault(t => t.BoardColumnId == jsonData.BoardColumnId); if (column == null) { return(NotFound()); } try { _context.Remove(column); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } //var jsonString = JsonConvert.SerializeObject(column); return("{}"); }
public ActionResult DeleteConfirmed(int id) { BoardColumn boardColumn = db.Columns.Find(id); db.Columns.Remove(boardColumn); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <bool> Delete(int id) { BoardColumn boardColumn = context.BoardColumns.Find(id); context.BoardColumns.Remove(boardColumn); int saveResult = await context.SaveChangesAsync(); return(saveResult == 1); }
public ActionResult Edit([Bind(Include = "BoardColumnId,ColumnName")] BoardColumn boardColumn) { if (ModelState.IsValid) { db.Entry(boardColumn).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(boardColumn)); }
public void Init(Material material, BoardColumn boardColumn) { // Assign material GetMaterial(material); // Assign host column hostColumn = boardColumn; // Init rotation speed rotationSpeed = 20; }
// Use this for initialization void Start() { this.spawnPositions = new Vector2[boardWidth]; this.columns = new BoardColumn[boardWidth]; float maxBoardHeight = boardHeight; // * gemSize; float maxBoardWidth = boardWidth; // * gemSize; float heightAdjust = -0.5f; if (maxBoardHeight % 2 == 0) { heightAdjust = -0.5f; } float topOfBoard = (maxBoardHeight / 2) + 1 + heightAdjust; float widthAdjust = 0.5f; if (maxBoardWidth % 2 == 0) { widthAdjust = 0.5f; } float xSpawnPoint = ((maxBoardWidth / 2) * -1) + widthAdjust; float bottomSlot = -1 * (maxBoardHeight / 2) - heightAdjust; float[] slotHeights = new float[boardHeight]; for (int i = 0; i < boardHeight; i++) { slotHeights [i] = bottomSlot + i; } for (int i = 0; i < boardWidth; i++) { spawnPositions [i] = new Vector2(xSpawnPoint + i, topOfBoard); GameObject go = (GameObject)Instantiate(Resources.Load(columnPrefabString, typeof(GameObject))); go.transform.SetParent(this.transform); go.transform.localScale = new Vector3(1, boardHeight, 1); go.transform.localPosition = new Vector3(spawnPositions[i].x, 0, 0); BoardColumn col = go.GetComponent <BoardColumn> (); this.columns[i] = col; col.SetColNum(i); col.SetSlots(slotHeights); } float bottomOfBoard = -1 * ((maxBoardHeight / 2) + 1 + heightAdjust); this.boardBottom.transform.localPosition = new Vector2(0, bottomOfBoard); StartCoroutine(SpawnGemTimer()); }
public ActionResult Create([Bind(Include = "BoardColumnId,ColumnName")] BoardColumn boardColumn, int?boardId) { if (ModelState.IsValid) { db.Boards.Find(boardId).Columns.Add(boardColumn); db.SaveChanges(); return(RedirectToAction("Details", "KanbanBoards", new { id = boardId })); } return(View(boardColumn)); }
public async Task <IActionResult> Create([Bind("BoardColumnId,Title,BoardId")] BoardColumn boardColumn) { if (ModelState.IsValid) { _context.Add(boardColumn); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BoardId"] = new SelectList(_context.Boards, "BoardId", "BoardId", boardColumn.BoardId); return(View(boardColumn)); }
public async Task <bool> SaveBoardColumn(BoardColumn boardColumn, string slug, Board currentBoard) { boardColumn.BoardColumnSlug = slug; boardColumn.Board = currentBoard; boardColumn.BoardColumnSorting = 100; await context.BoardColumns.AddAsync(boardColumn); int saveResult = await context.SaveChangesAsync(); return(saveResult == 1); }
public void GiveAObjWhenIsABoardColumnThenReturnsTrue() { // Arrange SetupState(); var boardColumn = new BoardColumn(); // Act var isAppliable = state.IsAppliable(boardColumn); // Assert Assert.True(isAppliable); }
public async void GivenABoardSlugAndBoardColumnWhenBoardIsNotFoundThenReturnNotFound() { // Arrange SetupController(); var boardSlug = "test"; var column = new BoardColumn(); // Act var notFoundResult = await controller.Post(boardSlug, column) as NotFoundResult; // Assert Assert.NotNull(notFoundResult); }
public void GivenAObjWhenIsABoardColumnThenSelfLinkAdded() { // Arrange SetupState(); mockLinkFactory.Setup(x => x.Build("BoardColumnsGet", It.IsAny <object>())).Returns("http://fake-url/"); var boardColumn = new BoardColumn(); // Act state.Apply(boardColumn); // Assert Assert.NotNull(boardColumn.Links); Assert.NotNull(boardColumn.Links.FirstOrDefault(x => x.Rel == Link.SELF)); }
// GET: BoardColumns/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BoardColumn boardColumn = db.Columns.Find(id); if (boardColumn == null) { return(HttpNotFound()); } return(View(boardColumn)); }
public ActionResult <string> EditTask() { var output = ""; using (StreamReader reader = new StreamReader(Request.Body)) { output = reader.ReadToEnd(); } RequestData jsonData = JsonConvert.DeserializeObject <RequestData>(output); Models.Task task = _context.Tasks.FirstOrDefault(t => t.TaskId == jsonData.TaskId); BoardColumn column = _context.BoardColumns.FirstOrDefault(t => t.BoardColumnId == jsonData.BoardColumnId); if (task == null) { return(NotFound()); } if (column != null) { task.BoardColumnId = column.BoardColumnId; } if (!String.IsNullOrWhiteSpace(jsonData.Title)) { task.Title = jsonData.Title; } if (!String.IsNullOrWhiteSpace(jsonData.Content)) { task.Content = jsonData.Content; } try { _context.Update(task); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } var jsonString = JsonConvert.SerializeObject(task, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore } ); return(jsonString); }
public async void GivenABoardSlugAndBoardColumnWhenBoardDoesNotExistThenNotFound() { // Arrange SetupController(); var boardSlug = "test"; var column = new BoardColumn(); mockCommandDispatcher.Setup( x => x.HandleAsync <CreateBoardColumnCommand, BoardColumn>(It.IsAny <CreateBoardColumnCommand>())) .Throws <BoardNotFoundException>(); // Act var notFoundResult = await controller.Post(boardSlug, column) as NotFoundResult; // Assert Assert.NotNull(notFoundResult); }
public async void GivenABoardSlugAndBoardColumnWhenSlugForBoardColumnExistsThenConflictReturned() { // Arrange SetupController(); var boardSlug = "test"; var column = new BoardColumn(); mockCommandDispatcher.Setup( x => x.HandleAsync <CreateBoardColumnCommand, BoardColumn>(It.IsAny <CreateBoardColumnCommand>())) .Throws <CreateBoardColumnCommandSlugExistsException>(); // Act var conflictResult = await controller.Post(boardSlug, column) as ConflictResult; // Assert Assert.NotNull(conflictResult); }
public ActionResult <string> GetColumn(int?id) { BoardColumn column = _context.BoardColumns.Include(c => c.Tasks).FirstOrDefault(b => b.BoardColumnId == id); if (column == null) { return(NotFound()); } var jsonString = JsonConvert.SerializeObject(column, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore } ); return(jsonString); }
public async void GivenBoardSlugAndBoardColumnSlugAndBoardColumnWhenOkThenHyperMediaApplied() { // Arrange SetupController(); const string boardSlug = "board-name"; const string boardColumnSlug = "board-column-name"; var boardColumn = new BoardColumn(); mockCommandDispatcher.Setup( x => x.HandleAsync <UpdateBoardColumnCommand, BoardColumn>(It.IsAny <UpdateBoardColumnCommand>())) .ReturnsAsync(boardColumn); // Act await controller.Put(boardSlug, boardColumnSlug, boardColumn); // Assert mockHyperMediaFactory.Verify(x => x.Apply(It.IsAny <BoardColumn>()), Times.Once); }
public async void GivenBoardSlugAndBoardColumnSlugAndBoardWhenUpdatedThenOkResultReturned() { // Arrange SetupController(); const string boardSlug = "board-name"; const string boardColumnSlug = "board-column-name"; var boardColumn = new BoardColumn(); mockCommandDispatcher.Setup( x => x.HandleAsync <UpdateBoardColumnCommand, BoardColumn>(It.IsAny <UpdateBoardColumnCommand>())) .ReturnsAsync(boardColumn); // Act var okNegotiatedContentResult = await controller.Put(boardSlug, boardColumnSlug, boardColumn) as OkNegotiatedContentResult <BoardColumn>; // Assert Assert.NotNull(okNegotiatedContentResult); }
public async void GivenBoardSlugAndBoardColumnSlugAndBoardWhenBoardColumnDoesNotExistThenNotFonndReturned() { // Arrange SetupController(); const string boardSlug = "board-name"; const string boardColumnSlug = "board-column-name"; var boardColumn = new BoardColumn(); mockCommandDispatcher.Setup( x => x.HandleAsync <UpdateBoardColumnCommand, BoardColumn>(It.IsAny <UpdateBoardColumnCommand>())) .Throws <BoardColumnNotFoundException>(); // Act var notFoundResult = await controller.Put(boardSlug, boardColumnSlug, boardColumn) as NotFoundResult; // Assert Assert.NotNull(notFoundResult); }