Exemplo n.º 1
0
        public async Task <IActionResult> Announcements(bool activeOnly = true)
        {
            var user = await userManager.GetUserAsync(User);

            AnnouncementRepository   repo = new AnnouncementRepository(configModel.ConnectionString);
            List <AnnouncementModel> announcements;

            // Ensure that ONLY staff accounts have access to this API endpoint
            if (user == null || !await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString()))
            {
                activeOnly = true;
            }

            try
            {
                announcements = repo.GetAnnouncementList(activeOnly);
            }
            catch (Exception e)
            {
                return(Utilities.ErrorJson(e.Message));
            }

            return(new JsonResult(new
            {
                Error = "",
                Announcements = announcements
            }));
        }
Exemplo n.º 2
0
        // GET: Admin/Announcement/Manage
        public ActionResult Manage()
        {
            try
            {
                var _announcementList = new List <AnnouncementInfo>();

                using (AnnouncementRepository Repo = new AnnouncementRepository())
                {
                    _announcementList = Repo.GetAnnouncementList();
                }

                return(View(_announcementList));
            }

            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "Announcement", "Manage")));
            }
        }
        public IHttpActionResult AnnouncementList()
        {
            var announcements = announcement_repository.GetAnnouncementList();

            return(Ok(AnnouncementListItem.MapTo(announcements)));
        }