示例#1
0
        public async Task <IActionResult> EditGroup(int?id)
        {
            int gid;

            if (id != null)
            {
                gid = id ?? 0;
                ViewData["Admin"] = true;
            }
            else
            {
                var t = _taskDispatcher.GetNextToDo()?.GroupId;
                if (t == null)
                {
                    // no more tasks
                    return(View("NoTasks"));
                }
                gid = (int)t;
                ViewData["Admin"] = false;
            }

            if (!(await _logic.GroupExists(gid)))
            {
                return(View("Error"));
            }
            var fields = _logic.GetLastestVersionFields(gid);
            var types  = _logic.GetAllFieldTypesByGroup(gid);

            //legacy view
            if (id != null)
            {
                return(View("LegacyEditGroup", await FieldsToGroupViewModel(gid, fields, types)));
            }
            return(View(await FieldsToGroupViewModel(gid, fields, types)));
        }
示例#2
0
        public IActionResult GroupDetails(int id)
        {
            //TODO: Authentication: Admin Only
            var versions           = _logic.GetAllVersions(id);
            var versionsWithFields = new List <Dictionary <FieldType, string> >();

            foreach (var version in versions)
            {
                versionsWithFields.Add(_logic.GetVersionFields(version));
            }

            var vm = new GroupDetailsViewModel()
            {
                Group       = _context.Groups.Single(g => g.GroupId == id),
                Versions    = versionsWithFields,
                RawVersions = versions.ToList(),
                FieldTypes  = _logic.GetAllFieldTypesByGroup(id)
            };

            return(View("GroupDetails", vm));
        }