Ejemplo n.º 1
0
        public async Task <ActionResult> EditStatus()
        {
            var datasets = (await dataQualityWriteService.GetDataQualityStatus()).Select(d => new DataQualityStatusItem
            {
                EstablishmentType = d.EstablishmentType,
                LastUpdated       = new DateTimeViewModel(d.LastUpdated)
            })
                           .ToList();

            var data = new EditDataQualityStatusViewModel
            {
                Items = new List <DataQualityStatusItem>()
            };

            foreach (var kvp in _roleToDataSetMappings)
            {
                if (User.InRole(kvp.Key, EdubaseRoles.ROLE_BACKOFFICE))
                {
                    var item = new DataQualityStatusItem {
                        EstablishmentType = kvp.Value
                    };

                    if (User.IsInRole(EdubaseRoles.ROLE_BACKOFFICE))
                    {
                        item.LastUpdated = datasets.FirstOrDefault(d => d.EstablishmentType == kvp.Value)?.LastUpdated;
                    }

                    data.Items.Add(item);
                }
            }
            data.Items.Sort((x, y) => x.EstablishmentType.GetEnumMember().CompareTo(y.EstablishmentType.GetEnumMember()));
            return(View(data));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> EditStatus(EditDataQualityStatusViewModel model)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in model.Items)
                {
                    await dataQualityWriteService.UpdateDataQualityDate(item.EstablishmentType,
                                                                        item.LastUpdated.ToDateTime().Value);
                }

                return(RedirectToAction("ViewStatus", new { dataUpdated = true }));
            }

            return(View(model));
        }