public IActionResult Index()
        {
            xmlService = new XmlService();
            string str  = xmlService.XmlToString();
            var    list = xmlService.ConvertXmlToList(str);

            ViewBag.XmlList = list;

            if (User.IsInRole("admin"))
            {
                return(RedirectToAction("Index", "Admin"));
            }

            if (User.Identity.IsAuthenticated)
            {
                UserIndexViewModel model = new UserIndexViewModel();

                string   UserIdFromUsers  = userService.FindUserByName(User.Identity.Name).Id;
                string   userName         = string.Empty;
                string   logoCompany      = string.Empty;
                int      userId           = 0;
                UserInfo userFromUserInfo = userService.FindUserByIdInUserInfo(UserIdFromUsers, ref userName, ref userId);
                if (userFromUserInfo == null)
                {
                    EmployeeInfo userFromEmployeeInfo = userService.FindUserByIdInCompany(UserIdFromUsers, ref userName, ref userId);
                    model.UserAccounts = accountService.GetCompanyAccounts(userId);
                    if (companyService.FindCompanyById(userId).Logo != null)
                    {
                        logoCompany = companyService.FindCompanyById(userId).Logo;
                    }
                }
                else
                {
                    model.UserAccounts = accountService.GetUserInfoAccounts(userId);
                }

                if (userId != 0)
                {
                    model.UserId   = userId;
                    model.UserName = userName;
                }
                HttpContext.Session.SetString("FullName", userName);
                HttpContext.Session.SetString("Logo", logoCompany);

                model.NBKRRates   = exchangeRateService.GetLastExchangeRatesByDate().Where(r => r.ExchangeRateTypeId == 1).ToList();
                model.MarketRates = exchangeRateService.GetLastExchangeRatesByDate().Where(r => r.ExchangeRateTypeId == 2).ToList();

                return(View(model));
            }

            return(RedirectToAction("Login"));
        }
        public ActionResult Index()
        {
            if (!User.IsInRole("admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ExchangeRatesListViewModel model = new ExchangeRatesListViewModel()
            {
                exchangeRatesList = exchangeRateService.GetLastExchangeRatesByDate(),
                currencyList      = currencyService.GetCurrencies().ToList()
            };

            return(View(model));
        }
Beispiel #3
0
        public void GetLastExchangeRatesByDate()
        {
            IQueryable <ExchangeRate> exchangeList = exchangeRateService.GetLastExchangeRatesByDate();
            bool IsInList = exchangeList.Any(r => r.RateDate == GetLastExchangeRate().RateDate);

            Assert.True(IsInList);
        }