Example #1
0
        public IEnumerable <ListViewModel> SortingFilteringPaging(string sortOrder, string searchString, int pagenumber, int boardid, string boardname)
        {
            IEnumerable <ListViewModel> lists;

            switch (sortOrder)
            {
            case ListVMConstants.NameDesc:
                lists = VMConverters.ModelsToViewModels(_lr.GetListsOfBoardPaging(e => e.Name, SortDirection.Descending, searchString, pagenumber, PageSize, boardid), boardname);
                break;

            case ListVMConstants.NameAsc:
                lists = VMConverters.ModelsToViewModels(_lr.GetListsOfBoardPaging(e => e.Name, SortDirection.Ascending, searchString, pagenumber, PageSize, boardid), boardname);
                break;

            case ListVMConstants.LixDesc:
                lists = VMConverters.ModelsToViewModels(_lr.GetListsOfBoardPaging(e => e.Lix, SortDirection.Descending, searchString, pagenumber, PageSize, boardid), boardname);
                break;

            case ListVMConstants.LixAsc:
                lists = VMConverters.ModelsToViewModels(_lr.GetListsOfBoardPaging(e => e.Lix, SortDirection.Ascending, searchString, pagenumber, PageSize, boardid), boardname);
                break;

            default:     // Lix ascending
                lists = VMConverters.ModelsToViewModels(_lr.GetListsOfBoardPaging(e => e.Lix, SortDirection.Ascending, searchString, pagenumber, PageSize, boardid), boardname);
                break;
            }
            return(lists);
        }
Example #2
0
        public static void BoardValidator(ModelStateDictionary ms, BoardViewModel boardvm)
        {
            List <KeyValuePair <BoardValidationCodes, KeyValuePair <string, string> > > errorMsgDic;

            BoardBusiness.ValidateBoard(VMConverters.ViewModelToModel(boardvm), null, out errorMsgDic);
            foreach (var error in errorMsgDic)
            {
                ms.AddModelError(error.Value.Key, error.Value.Value);
            }
        }
Example #3
0
        public IEnumerable <CardViewModel> SortingFilteringPaging(string sortOrder, string searchString, int pagenumber, int listid, string listname)
        {
            IEnumerable <CardViewModel> cards;

            switch (sortOrder)
            {
            case CardVMConstants.NameDesc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.Name, SortDirection.Descending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.NameAsc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.Name, SortDirection.Ascending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.DiscriptionDesc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.Discription, SortDirection.Descending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.DiscriptionAsc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.Discription, SortDirection.Ascending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.CDateDesc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.CreationDate, SortDirection.Descending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.CDateAsc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.CreationDate, SortDirection.Ascending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.DueDateDesc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.DueDate, SortDirection.Descending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.DueDateAsc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.DueDate, SortDirection.Ascending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.CixDesc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.Cix, SortDirection.Descending, searchString, pagenumber, PageSize, listid), listname);
                break;

            case CardVMConstants.CixAsc:
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.Cix, SortDirection.Ascending, searchString, pagenumber, PageSize, listid), listname);
                break;

            default:     // Cix ascending
                cards = VMConverters.ModelsToViewModels(_cr.GetCardsOfListPaging(e => e.Cix, SortDirection.Ascending, searchString, pagenumber, PageSize, listid), listname);
                break;
            }
            return(cards);
        }
Example #4
0
 public async Task <ActionResult> Create([Bind(Include = "Name, Discription")] BoardViewModel boardvm)
 {
     if (_br.HasRepeatedBoardName(boardvm.Id, boardvm.Name))
     {
         ModelState.AddModelError("Name", BoardResources.BoardNameAlreadyExists);
     }
     if (ModelState.IsValid)
     {
         _br.Add(VMConverters.ViewModelToModel(boardvm));
         return(RedirectToAction("Index"));
     }
     return(View(boardvm));
 }
Example #5
0
 public ActionResult Create(int?boardid, [Bind(Include = "Lix,Name")] ListViewModel listvm)
 {
     if (boardid == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (ModelState.IsValid)
     {
         var list = VMConverters.ViewModelToModel(listvm, boardid.Value);
         _lr.Add(list);
         return(RedirectToAction("ListsOfBoard"));
     }
     return(View());
 }
Example #6
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var board = _br.GetSingle(id.Value);

            if (board == null)
            {
                return(HttpNotFound());
            }
            return(View(VMConverters.ModelToViewModel(board)));
        }
Example #7
0
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //Board board = await db.Board.FindAsync(id);
            Board board = _br.GetSingle(id.Value);

            if (board == null)
            {
                return(HttpNotFound());
            }
            return(View(VMConverters.ModelToViewModel(board)));
        }
Example #8
0
 public async Task <ActionResult> Edit(int?boardid, int?listid, int?id, [Bind(Include = "Cix,Name,Discription,DueDate")] CardViewModel cardvm)
 {
     if (boardid == null || listid == null || id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (ModelState.IsValid)
     {
         cardvm.Id = id.Value;
         _cr.Edit(VMConverters.ViewModelToModel(cardvm, boardid.Value, listid.Value));
         return(RedirectToAction("CardsOfList"));
     }
     ViewBag.BoardId = boardid.Value;
     ViewBag.ListId  = listid.Value;
     return(View(cardvm));
 }
Example #9
0
        public ActionResult Delete(int?boardid, int?id)
        {
            if (boardid == null || id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var list = _lr.GetSingle(id.Value);

            if (list == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BoardId = boardid.Value;
            var boardname = _lr.GetListBoardName(boardid.Value);

            return(View(VMConverters.ModelToViewModel(list, boardname)));
        }
Example #10
0
 public ActionResult Edit(int?boardid, int?id, [Bind(Include = "Lix,Name")] ListViewModel listvm)
 {
     if (boardid == null || id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     if (ModelState.IsValid)
     {
         //list.BoardId = _lr.GetSingle(list.ListId).BoardId;
         var list = VMConverters.ViewModelToModel(listvm, boardid.Value);
         _lr.Edit(list);
         return(RedirectToAction("Details", new { id = list.ListId }));
     }
     //ViewBag.BoardId = new SelectList(db.Board, "BoardId", "Name", list.BoardId);
     ViewBag.BoardId = boardid.Value;
     return(View(listvm));
 }
Example #11
0
 public async Task <ActionResult> Edit(int id, [Bind(Include = "Name, Discription")] BoardViewModel boardvm)
 {
     if (!_br.ValidId(id))
     {
         return(HttpNotFound());
     }
     boardvm.Id = id;
     if (_br.HasRepeatedBoardName(boardvm.Id, boardvm.Name))
     {
         ModelState.AddModelError("Name", BoardResources.BoardNameAlreadyExists);
     }
     if (!ModelState.IsValid)
     {
         return(View(boardvm));
     }
     _br.Edit(VMConverters.ViewModelToModel(boardvm));
     return(RedirectToAction("Index"));
 }
Example #12
0
        public async Task <ActionResult> Details(int?boardid, int?listid, int?id)
        {
            if (boardid == null || listid == null || id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var card = _cr.GetSingle(id.Value);

            if (card == null)
            {
                return(HttpNotFound());
            }
            var listname = _cr.GetCardListName(listid.Value);

            ViewBag.BoardId = boardid.Value;
            ViewBag.ListId  = listid.Value;
            return(View(VMConverters.ModelToViewModel(card, listname)));
        }
Example #13
0
        public ActionResult Edit(int?boardid, int?id)
        {
            if (boardid == null || id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //List list = db.List.Find(id);
            var list = _lr.GetSingle(id.Value);

            if (list == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.BoardId = new SelectList(db.Board, "BoardId", "Name", list.BoardId);
            ViewBag.BoardId = list.BoardId;
            var boardname = _lr.GetListBoardName(boardid.Value);

            return(View(VMConverters.ModelToViewModel(list, boardname)));
        }
Example #14
0
        /*[HttpGet]
         * [Route("CheckBoardName")]
         * public JsonResult CheckBoardName(string Name)
         * {
         *  var result = _br.HasRepeatedBoardName(id, Name);
         *  return Json(result, JsonRequestBehavior.AllowGet);
         * }
         */
        #endregion

        #region Auxiliar Methods
        public IEnumerable <BoardViewModel> SortingFilteringPaging(string sortOrder, string searchString, int pagenumber)
        {
            IEnumerable <BoardViewModel> boards;

            switch (sortOrder)
            {
            case BoardVMConstants.NameDesc:
                boards = VMConverters.ModelsToViewModels(_br.GetAllPaging(e => e.Name, SortDirection.Descending, searchString, pagenumber, PageSize));
                break;

            case BoardVMConstants.DiscriptionAsc:
                boards = VMConverters.ModelsToViewModels(_br.GetAllPaging(e => e.Discription, SortDirection.Ascending, searchString, pagenumber, PageSize));
                break;

            case BoardVMConstants.DiscriptionDesc:
                boards = VMConverters.ModelsToViewModels(_br.GetAllPaging(e => e.Discription, SortDirection.Descending, searchString, pagenumber, PageSize));
                break;

            default:     // Name ascending
                boards = VMConverters.ModelsToViewModels(_br.GetAllPaging(e => e.Name, SortDirection.Ascending, searchString, pagenumber, PageSize));
                break;
            }
            return(boards);
        }