Beispiel #1
0
        public async Task <ActionResult> Results(string q)
        {
            Tuple <List <NoticeBoardViewModel>, List <NoticeViewModel> > results = new Tuple <List <NoticeBoardViewModel>, List <NoticeViewModel> >(
                new List <NoticeBoardViewModel>(),
                new List <NoticeViewModel>()
                );

            using (NoticeBoardManager m = new NoticeBoardManager())
            {
                var boards = await m.SearchAsync(q);

                foreach (var i in boards)
                {
                    results.Item1.Add(NoticeBoardMappings.To <NoticeBoardViewModel>(i));
                }
            }

            using (NoticeManager m = new NoticeManager())
            {
                var notices = await m.SearchAsync(q);

                foreach (var i in notices)
                {
                    results.Item2.Add(NoticeMappings.To <NoticeViewModel>(i));
                }
            }

            return(View(results));
        }
        // GET: MyPosts
        public async Task <ActionResult> Index()
        {
            using (NoticeManager nm = new NoticeManager())
            {
                var user = await User.Identity.GetApplicationUserAsync();

                var approved = await nm.GetUserNoticesAsync(user.Id, 0, 6, Entities.Data.NoticeStatus.Approved);

                var pending = await nm.GetUserNoticesAsync(user.Id, 0, 6, Entities.Data.NoticeStatus.PendingApproval);

                var disapproved = await nm.GetUserNoticesAsync(user.Id, 0, 6, Entities.Data.NoticeStatus.Disapproved);

                MyPostViewModel pvm = new MyPostViewModel();

                foreach (var n in approved)
                {
                    pvm.ApprovedPosts.Add(NoticeMappings.To <DetailedNoticeViewModel>(n));
                }

                foreach (var n in pending)
                {
                    pvm.PendingPosts.Add(NoticeMappings.To <PendingNoticeViewModel>(n));
                }

                foreach (var n in disapproved)
                {
                    pvm.AmendedPosts.Add(NoticeMappings.To <AmendedNoticeViewModel>(n));
                }

                return(View(pvm));
            }
        }
        public async Task <ActionResult> Post(NoticeViewModel vm)
        {
            if (ModelState.IsValid)
            {
                NoticeManager nm = new NoticeManager();
                await nm.AddAsync(NoticeMappings.From(vm), await this.User.Identity.GetApplicationUserAsync());

                return(RedirectToAction("View", new { id = vm.NoticeBoardId }));
            }
            return(View(vm));
        }
        // GET: Pending
        public async Task <ActionResult> Index()
        {
            var pending_notices = await db.GetPendingAsync(0, 6);

            List <PendingNoticeViewModel> vmlist = new List <PendingNoticeViewModel>();

            foreach (var n in pending_notices)
            {
                vmlist.Add(NoticeMappings.To <PendingNoticeViewModel>(n));
            }
            return(View(vmlist));
        }
        public async Task <ActionResult> GetFeed(int?index, int?number)
        {
            int i = index ?? 0;
            int n = number ?? 5;

            NoticeManager nm = new NoticeManager();
            var           pending_notices = await db.GetPendingAsync(i, n);

            List <PendingNoticeViewModel> vmlist = new List <PendingNoticeViewModel>();

            foreach (var notice in pending_notices)
            {
                vmlist.Add(NoticeMappings.To <PendingNoticeViewModel>(notice));
            }
            return(View(vmlist));
        }
        public static NoticeBoardViewModel ToNoticeBoardViewModel(NoticeBoard nb)
        {
            var n = new List <NoticeViewModel>();

            nb.Notices.ForEach(x => n.Add(NoticeMappings.To <NoticeViewModel>(x)));
            NoticeBoardViewModel vm = new NoticeBoardViewModel
            {
                Id          = nb.NoticeBoardId,
                Title       = nb.Title,
                Description = nb.Description,
                IsOfficial  = nb.IsOfficial,
                IsMandatory = nb.IsMandatory,
                Notices     = n
            };

            return(vm);
        }
        public async Task <ActionResult> Notice(int?id)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            using (NoticeManager nm = new NoticeManager())
            {
                var n = await nm.GetDetailedAsync(id.Value);

                if (n == null)
                {
                    return(HttpNotFound());
                }

                return(View(NoticeMappings.To <DetailedNoticeViewModel>(n)));
            }
        }
Beispiel #8
0
        // GET: /GetFeed?index=6&number=5
        public async Task <ActionResult> GetFeed(int?index, int?number)
        {
            int i = index ?? 0;
            int n = number ?? 5;

            NoticeManager nm   = new NoticeManager();
            var           user = await User.Identity.GetApplicationUserAsync();

            var notices = await nm.GetNewsFeedAsync(user.Id, i, n);

            List <DetailedNoticeViewModel> vms = new List <DetailedNoticeViewModel>();

            foreach (var notice in notices)
            {
                vms.Add(NoticeMappings.To <DetailedNoticeViewModel>(notice));
            }

            return(View(vms));
        }
        // GET: /GetAmended?index=6&number=5
        public async Task <ActionResult> GetAmended(int?index, int?number)
        {
            using (NoticeManager nm = new NoticeManager())
            {
                int i    = index ?? 0;
                int n    = number ?? 5;
                var user = await User.Identity.GetApplicationUserAsync();

                var notices = await nm.GetUserNoticesAsync(user.Id, i, n, Entities.Data.NoticeStatus.Disapproved);

                List <AmendedNoticeViewModel> vm = new List <AmendedNoticeViewModel>();

                foreach (var notice in notices)
                {
                    vm.Add(NoticeMappings.To <AmendedNoticeViewModel>(notice));
                }

                return(View(vm));
            }
        }
Beispiel #10
0
        // Get:Boards/EditNotice/5

        public async Task <ActionResult> EditNotice(int id)
        {
            using (NoticeManager nm = new NoticeManager())
            {
                var notice = await nm.GetAsync(id);

                var board = await db.GetAsync(notice.NoticeBoardId);

                // access denied if user is not a staff and the notice board is official
                if (board.IsOfficial)
                {
                    if (!await User.Identity.IsStaffAsync())
                    {
                        throw new HttpException(403, "Access Denied");
                    }
                }

                var vm = NoticeMappings.To <NoticeViewModel>(notice);
                return(View(vm));
            }
        }
Beispiel #11
0
        public async Task <ActionResult> Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "About"));
            }

            NoticeManager nm   = new NoticeManager();
            var           user = await User.Identity.GetApplicationUserAsync();

            var notices = await nm.GetNewsFeedAsync(user.Id, 0, 6);

            List <DetailedNoticeViewModel> vms = new List <DetailedNoticeViewModel>();

            foreach (var n in notices)
            {
                vms.Add(await NoticeMappings.ToDetailedNoticeViewModelAsync(n));
            }

            return(View(vms));
        }