Ejemplo n.º 1
0
        public PageEntryModel Save()
        {
            var model = new PageEntryModel
            {
                Title             = Title,
                Category          = Category.DisplayName,
                Steps             = ProcessSteps.Where(s => s.IsPresent).Select(s => s.DisplayName).ToArray(),
                EntryDate         = EntryDate,
                NextSteps         = NextSteps.GetModel(),
                ItemsAccomplished = ItemsAccomplished.GetModel(),
                Attended          = AttendanceViewModel.GetModel(),
                Author            = AttendanceViewModel.Author?.DisplayName,
                Sections          = Sections.GetModel(),
                Reflections       = Reflections,
            };

            return(model);
        }
Ejemplo n.º 2
0
        public PageEntryViewModel Load(PageEntryModel model)
        {
            Title     = model.Title;
            EntryDate = model.EntryDate ?? DateTime.Now;

            if (model.Category != null)
            {
                model.Category = ModifyCategory(model.Category);

                Category = Category.AvailableCategories
                           .FirstOrDefault(c => c.DisplayName == model.Category);

                if (Category == null)
                {
                    Category = Category.AvailableCategories.FirstOrDefault(c => c.DisplayName == model.Category);
                }
            }

            if (model.Steps != null)
            {
                foreach (var step in model.Steps)
                {
                    var stepVm = FindStep(step);
                    if (stepVm != null)
                    {
                        stepVm.IsPresent = true;
                    }
                }
            }

            ItemsAccomplished.LodeModel(model.ItemsAccomplished);
            NextSteps.LodeModel(model.NextSteps);
            Sections.LoadModel(model.Sections);

            AttendanceViewModel.SetAuthorAndAttendees(model.Author, model.Attended);

            Reflections = model.Reflections;

            return(this);
        }