Exemple #1
0
        public ActionResult Add(LogsAddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var newModel = new LogsAddViewModel
                {
                    Goals   = LogsUtility.GetGoalDropdown(),
                    GoalLog = model.GoalLog
                };

                return(View("Add", newModel));
            }

            var log = new GoalLog
            {
                Date         = model.GoalLog.Date,
                WasCompleted = model.GoalLog.WasCompleted,
                GoalId       = model.GoalId
            };

            _context.GoalLogs.Add(log);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Goal"));
        }
Exemple #2
0
        public ActionResult Add()
        {
            var model = new LogsAddViewModel
            {
                Goals = LogsUtility.GetGoalDropdown()
            };

            return(View(model));
        }