private void AdjustListPosition(List l, Action<List> incOrDec)
 {
     DALUtils.AdjustPosition<List>(
             _repo[l.BoardName].Values,
             list => list.Position >= l.Position,
             incOrDec
             );
 }
 public void Add(List l)
 {
     if (_repo.ContainsKey(l.BoardName) && _repo[l.BoardName].ContainsKey(l.Name))
         throw new DuplicateKeyException();
     if (!_repo.ContainsKey(l.BoardName)) _repo[l.BoardName] = new Dictionary<string, List>();
     AdjustListPosition(l, item => item.Position++);
     _repo[l.BoardName][l.Name] = l;
 }
 internal static IEnumerable<int> GetAllCardsPositions(List list)
 {
     var cards = AppServices.GetCardsFromList(list);
     int pos = 1;
     int count = cards.Count();
     while (pos <= count)
     {
         yield return pos;
         pos += 1;
     }
 }
        public void Edit(List l)
        {
            //if(listForBoards.SingleOrDefault(list =>list.Position==l.Position)!=null)
            //{
            //    foreach (List list in listForBoards.Where(list => list.Position >= l.Position))
            //        list.Position++;
            //}

            AdjustListPosition(l, item => item.Position++);

            _repo[l.BoardName][l.Name] = l;
        }
        public ActionResult Create(List list)
        {
            try
            {
                AppServices.AddList(list);

                return RedirectToAction("Index", "Boards");
            }
            catch
            {
                return View("Form");
            }
        }
        public ActionResult Edit(string listId, List list)
        {
            try
            {
                AppServices.EditList(list);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 public void Remove(List l)
 {
     _repo[l.BoardName].Remove(l.Name);
     AdjustListPosition(l, item => item.Position--);
 }
 internal static IEnumerable<Card> OrderCardsFromList(List l)
 {
     return AppServices.GetCardsFromList(l)
         .Where(c => c.isArchived == false)
         .OrderBy(c => c.Position);
 }
 public static IEnumerable<Card> GetCardsFromList(List t)
 {
     var cards = GetAllCardsFromBoard(t.BoardName);
     if (cards == null) return null;
     return cards.Where(card => card.ListName == t.Name);
 }
 public static void EditList(List list)
 {
     _repoList.Edit(list);
 }
 public static void AddList(List list)
 {
     _repoList.Add(list);
 }
 public static void RemoveList(List list)
 {
     _repoList.Remove(list);
 }