Beispiel #1
0
        public ViewResult ListActiveSquawks()
        {
            List <Squawk> squawks = null;

            if (User.IsInRole("Admin"))
            {
                squawks = _dataService.GetAllSquawks();
            }
            else
            {
                squawks = _dataService.GetActiveSquawks();
            }

            SquawkListViewModel model = new SquawkListViewModel();

            if (squawks != null && squawks.Count > 0)
            {
                model.SquawkList = squawks.Select(s => new SquawkListItemViewModel()
                {
                    Id         = s.Id,
                    PostedBy   = s.PostedBy.FullName,
                    PostedOn   = s.PostedOn,
                    Status     = s.Status,
                    Subject    = s.Subject,
                    TailNumber = s.Aircraft.RegistrationNumber
                }).ToList();
            }

            return(View(ViewNames.ActiveSquawks, model));
        }