示例#1
0
        /// <summary>
        /// Method that logs a user into the system
        /// </summary>
        /// <param name="username">A username string that is passed to this method</param>
        /// <param name="password">A password string that is passed to this method</param>
        public static async void Login(string username, string password)
        {
            foreach (Account account in _accountList.AccountList)
            {
                if (username == account.UserName && password == account.PassWord)
                {
                    _account            = new Account(account.UserName, account.PassWord, account.DisplayName);
                    SetDisplayNameForUI = _account.DisplayName;
                    AccountDetail       = new AccountDetails();
                    _accountDetails     = await AccountDetail.LoadUserDetailsFile(username);

                    SetProfileImagePathForUI = _accountDetails.ProfilePicturePath;
                    MainPageVm?.CallForAccountStatus();
                    StoreVm?.OnAccountChanged();
                    GameTemplateVm?.OnAccountChanged();
                    if (AccountDetail.AccountShoppingCart != null)
                    {
                        if (AccountDetail.AccountShoppingCart.Count > 0)
                        {
                            ShoppingCart.Instance.AddGame(AccountDetail?.AccountShoppingCart);
                        }
                    }
                    else
                    {
                        AccountDetail.AccountShoppingCart = new ObservableCollection <Game>();
                    }
                    MainPageVm?.RefreshPurchaseSelectedGame();
                    break;
                }
            }
        }
示例#2
0
 public IActionResult Create(StoreVm form)
 {
     if (ModelState.IsValid)
     {
         Store formCo = _mapper.Map <Store>(form);
         _unitOfWork.Stores.Add(formCo);
         _unitOfWork.Complate();
         TempData["Message"] = "Sikeres hozzáadás!";
         return(RedirectToAction(nameof(Index)));
     }
     return(View(form));
 }
示例#3
0
        public IActionResult Edit(StoreVm form)
        {
            if (ModelState.IsValid)
            {
                Store storeCo = _mapper.Map <Store>(form);
                _unitOfWork.Stores.Update(storeCo);
                _unitOfWork.Complate();

                TempData["Message"] = "A változtatásokat sikeresen elmentettük!";
                return(RedirectToAction(nameof(Index)));
            }
            return(View(form));
        }
示例#4
0
 /// <summary>
 /// Creates an account in the system and writes the account to the files
 /// </summary>
 /// <param name="account">An account object that is passed</param>
 /// <param name="pfpPath">A string that is passed that links an image to the account</param>
 public static void CreateAccount(Account account, string pfpPath)
 {
     _accountList.AccountList.Add(account);
     SetDisplayNameForUI                = _account.DisplayName;
     AccountDetail                      = new AccountDetails();
     _accountDetails.DisplayName        = account.DisplayName;
     _accountDetails.UserName           = account.UserName;
     _accountDetails.ProfilePicturePath = pfpPath;
     SetProfileImagePathForUI           = _accountDetails.ProfilePicturePath;
     _joinDateBeforeFormat              = DateTime.Now;
     _accountDetails.JoinDate           = _joinDateBeforeFormat.Date.ToShortDateString();
     _accountDetails.CreateUserDetailsFile(_accountDetails, account.UserName);
     MainPageVm?.CallForAccountStatus();
     StoreVm?.OnAccountChanged();
     GameTemplateVm?.OnAccountChanged();
 }
示例#5
0
        public ActionResult Store(StoreVm model)
        {
            if (ModelState.IsValid)
            {
                Entity.EntityModels.Store store = Mapper.Map <Entity.EntityModels.Store>(model);
                if (store.Id == 0)
                {
                    ViewBag.message = storeManager.Save(store);
                }
                else
                {
                    ViewBag.message = storeManager.Update(store);
                }
                model = new StoreVm();
                ModelState.Clear();
            }
            List <Store> stores = storeManager.GetAllStore();

            ViewBag.Store = stores;
            return(View(model));
        }
示例#6
0
        /// <summary>
        /// Logs a user off the system and sets objects to null
        /// </summary>
        public static void LogOff()
        {
            _accountDetails.CreateUserDetailsFile(_accountDetails, _account.UserName);

            //Bellow needs implementing without errors

            /*foreach (Game game in AccountDetail.AccountShoppingCart.Games)
             * {
             *  ShoppingCart.Instance.RemoveGame(game);
             * }*/


            _account                 = null;
            _displaynameForUI        = null;
            _accountDetails          = null;
            SetProfileImagePathForUI = null;
            MainPageVm?.CallForAccountStatus();
            StoreVm?.OnAccountChanged();
            GameTemplateVm?.OnAccountChanged();
            ShoppingCart.Instance.ClearShoppingCart();
            MainPageVm?.RefreshPurchaseSelectedGame();
        }