public IActionResult Index()
        {
            _logger.LogInfo($"Zapytanie do metody Index()");

            ViewBag.ErrorMsg = string.Empty;
            if (TempData.ContainsKey("ErrorMsg"))
            {
                ViewBag.ErrorMsg = TempData["ErrorMsg"];
                TempData.Remove("ErrorMsg");
            }

            var result = _repo.Get();

            if (!result.IsSuccess)
            {
                ViewBag.ErrorMsg = result.FailureMessage;
                return(View(new ApothecaryViewModel[] { }));
            }
            else
            {
                var apothecaries = result.Value.Select(x => (ApothecaryViewModel)x);
                return(View(apothecaries));
            }
        }
Beispiel #2
0
        public Result <IEnumerable <ApothecarySelectViewModel> > GetApothecarySelectList()
        {
            return(Try(() =>
            {
                var result = _apothecaryRepo.Get();

                if (!result.IsSuccess)
                {
                    throw new Exception(result.FailureMessage);
                }

                var temp = Map <IEnumerable <ApothecaryViewModel> >(result.Value.Where(x => !x.FireDate.HasValue));
                return Map <IEnumerable <ApothecarySelectViewModel> >(temp);
            }, GetType()));
        }