// GET: Admin/Categories/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var category = await _categoryDsl.FindById(id).ConfigureAwait(false);

            if (category == null)
            {
                return(NotFound());
            }

            return(View(category));
        }
Example #2
0
        public async Task <IActionResult> Create(/*[Bind("Notice.Id,Notice.Subject,Notice.Description,Notice.CreatedAt,Notice.IsActive")]*/ NoticeViewModel viewModel)
        {
            NoticeViewModel noticeViewModel = new NoticeViewModel
            {
                Categories = _categoryAdminManager.findAll(),
                Users      = _userAdminManager.FindAll()
            };

            if (ModelState.IsValid)
            {
                if (viewModel.Notice != null)
                {
                    Notice notice = viewModel.Notice;
                    notice.Category = _categoryAdminManager.FindById(viewModel.CategoryId).Result;
                    notice.Creator  = _userAdminManager.FindById(viewModel.CreatorId);
                    await _noticesAdminManager.Add(notice);

                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(View(noticeViewModel));
        }