Example #1
0
        public ActionResult LogbookEntry(Guid logbookEntryId)
        {
            ViewBag.BackLinkHtml = MenuConstructor.ConstructHtmlBackLink("LogbookEntry", logbookEntryId);
            var entry = DataAccess.GetLogbookEntry(logbookEntryId);
            var model = new LogbookEntryViewModel();

            model.Notes          = entry.Notes;
            model.EntryDate      = entry.EntryDate;
            model.Logbook        = DataAccess.GetLogbook(entry.LogbookId);
            model.ActivityId     = entry.ActivityId;
            model.LogbookEntryId = logbookEntryId;
            // format the option selections for readability.
            var fields = DataAccess.GetSelectedFields(logbookEntryId);
            Dictionary <string, string> selectedFieldText = new Dictionary <string, string>();

            foreach (var f in fields)
            {
                if (selectedFieldText.ContainsKey(f.FieldName))
                {
                    selectedFieldText[f.FieldName] += ", " + f.OptionText;
                }
                else
                {
                    selectedFieldText.Add(f.FieldName, f.OptionText);
                }
            }
            model.SelectedFields = selectedFieldText.Select(f => new SelectedFieldOption()
            {
                FieldName = f.Key, OptionText = f.Value
            }).ToArray();
            return(View(model));
        }
        public ActionResult EditFieldOption(Guid fieldOptionId)
        {
            ViewBag.BackLinkHtml = MenuConstructor.ConstructHtmlBackLink("EditFieldOption", fieldOptionId);
            var model = new EditFieldOptionViewModel();
            var dto   = DataAccess.GetFieldOption(fieldOptionId);

            model.FieldOptionId = fieldOptionId;
            model.Text          = dto.Text;
            return(View(model));
        }
        public ActionResult EditActivity(Guid activityId)
        {
            ViewBag.BackLinkHtml = MenuConstructor.ConstructHtmlBackLink("EditActivity", activityId);
            var model = new EditActivityViewModel();
            var dto   = DataAccess.GetActivity(activityId);

            model.Name        = dto.Name;
            model.Description = dto.Description;
            model.ImageUrl    = dto.ImageUrl;
            model.Fields      = DataAccess.GetFields(activityId);
            return(View(model));
        }
Example #4
0
        public ActionResult Logbook(Guid logbookId)
        {
            ViewBag.BackLinkHtml = MenuConstructor.ConstructHtmlBackLink("Logbook", logbookId);
            var logbook    = new LogbookViewModel();
            var logbookDTO = DataAccess.GetLogbook(logbookId);

            logbook.Name        = logbookDTO.Name;
            logbook.Activity    = DataAccess.GetActivity(logbookDTO.DefaultActivityId).Name;
            logbook.LastUpdated = logbookDTO.UpdateDate;
            logbook.LogbookId   = logbookDTO.LogbookId;
            logbook.Entries     = DataAccess.GetLogbookEntries(logbook.LogbookId);
            return(View(logbook));
        }
        public ActionResult EditField(Guid fieldId)
        {
            ViewBag.BackLinkHtml = MenuConstructor.ConstructHtmlBackLink("EditField", fieldId);
            var model = new EditFieldViewModel();
            var dto   = DataAccess.GetField(fieldId);

            model.FieldId       = dto.FieldId;
            model.Name          = dto.Name;
            model.AllowFreeText = dto.AllowFreeText;
            model.IsMultiSelect = dto.IsMultiSelect;
            model.IsRequired    = dto.IsRequired;
            model.FieldOptions  = DataAccess.GetFieldOptions(fieldId);
            return(View(model));
        }