Пример #1
0
        public async Task <ActionResult> Objective(int id)
        {
            ObjectiveViewModel model = new ObjectiveViewModel();

            List <String> destNames = new List <String>()
            {
                indexDestName
            };

            model.Parser = HomeController.CreateBBCodeParser();

            model.Objective = objectiveService.GetObjectiveByID(id);

            if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
            {
                model.Initialize((await objectiveService.GetCurrentUser()), CreateObjectivesAdminNavList(destNames));
            }
            else
            {
                model.Initialize((await objectiveService.GetCurrentUser()), CreateObjectivesNavList(destNames));
            }

            model.BalanceEntries = model.SkipAndTake <BalanceEntry>(model.Objective.BalanceEntries.OrderByDescending(b => b.Date));

            if (model.Objective == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Пример #2
0
        public async Task <ActionResult> Objective(ObjectiveViewModel model, int id)
        {
            List <String> destNames = new List <String>()
            {
                indexDestName
            };

            model.Parser    = HomeController.CreateBBCodeParser();
            model.Objective = objectiveService.GetObjectiveByID(id);

            if (User.Identity.IsAuthenticated && User.IsInRole("Admin"))
            {
                model.Initialize((await objectiveService.GetCurrentUser()), CreateObjectivesAdminNavList(destNames));
            }
            else
            {
                model.Initialize((await objectiveService.GetCurrentUser()), CreateObjectivesNavList(destNames));
            }


            if (model.Objective == null)
            {
                return(RedirectToAction("Index"));
            }

            model.BalanceEntries = model.SkipAndTake <BalanceEntry>(model.Objective.BalanceEntries.OrderByDescending(b => b.Date));

            // Clear the ModelState so changes in the model are reflected when using HtmlHelpers (their default behavior is to not use changes made to the model when re-rendering a view, not what we want here)
            ModelState.Clear();

            return(View(model));
        }