public bool AddList(int bid, List list) { int lid = ++lCount; list.Id = lid; if (GetBoard(bid) == null || GetList(bid, lid) != null) return false; listRepo[bid].AddLast(list); cardRepo[bid].Add(lid, new LinkedList<Card>()); return true; }
public ActionResult Create(string board, List l) { if(_repo.AddList(int.Parse(board), l)) return RedirectToAction("Details", "Board", new { id = board }); return new HttpNotFoundResult("Erro"); }
public ActionResult Edit(int board, List l, bool isAjaxRequest) { if (_repo.SubList(board, l)) { currUser = User.Identity.Name; int lid = l.Id; ListDetailsDTO listDto = new ListDetailsDTO(); listDto.SingleList = new Pair(currUser, l); listDto.IsOwned = _userRepo.IsUserBoard(board, currUser); listDto.IsVisual = _userRepo.BoardOnlyVis(board, currUser); listDto.BoardId = board; if (!isAjaxRequest) return View(listDto); return PartialView("ListDetailsPartial", listDto); } return View(_repo.GetList(board, l.Id)); }
public void MoveCardToOtherList(string card, string sender, string receiver, string previousCard, string nextCard, string board) { try { currUser = User.Identity.Name; int cid = int.Parse(card); int bid = int.Parse(board); int sid = int.Parse(sender); int rid = int.Parse(receiver); Card c = _repo.GetCard(bid, sid, cid); if (c == null) throw new HttpException("O Cartão não existe"); IDictionary<int, LinkedList<Card>> lists = _repo.ShowListsAndCards(bid); if (lists[sid] == null) throw new HttpException("A Lista de envio não existe"); if (lists[rid] == null) throw new HttpException("A Lista de recepção não existe"); //Get position List<Card> receiverCardList = new List<Card>(); if (lists[rid].First != null) receiverCardList = lists[rid].First.List.ToList<Card>(); int position = 0; if (receiverCardList.Count > 0) { if (!string.IsNullOrEmpty(previousCard)) { Card receiverCard = receiverCardList.Single(rc => rc.Id.Equals(int.Parse(previousCard))); position = receiverCardList.IndexOf(receiverCard) + 1; } else { if (!string.IsNullOrEmpty(nextCard)) { Card receiverCard = receiverCardList.Single(rc => rc.Id.Equals(int.Parse(nextCard))); position = receiverCardList.IndexOf(receiverCard); } } } //Move Card _repo.MoveCard(bid, sid, rid, cid, position); } catch (HttpException ex) { throw ex; } }
public bool SubList(int bid, List l) { foreach (List li in listRepo[bid]) if (li.Id == l.Id) { li.Name = l.Name; return true; } return false; }