Esempio n. 1
0
        // GET: Catalogs
        public async Task <ActionResult> Index()
        {
            var catalogs = new List <ListCatalogViewModel>();

            try
            {
                var result = await _catalogService.FindAll();

                if (!result.Success)
                {
                    Alert($"{result.Message}", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                    return(View(catalogs));
                }

                foreach (var catalog in result.Data)
                {
                    catalogs.Add(new ListCatalogViewModel
                    {
                        Id              = catalog.Id,
                        Code            = catalog.Code,
                        Description     = catalog.Description,
                        Name            = catalog.Name,
                        DateCreated     = catalog.CreatedAt,
                        DateLastUpdated = catalog.LastUpdated,
                        EffectiveDate   = catalog.EffectiveDate,
                        EndDate         = catalog.EndDate,
                        Published       = catalog.Published ? "Yes" : "No"
                    });
                }

                return(View(catalogs));
            }
            catch (Exception ex)
            {
                Alert($"Error! {ex.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                return(View(catalogs));
            }
        }