Exemplo n.º 1
0
        public async Task <IActionResult> MaskPage(string id)
        {
            Guid pageMaskId;

            try
            {
                pageMaskId = GuidEncoder.Decode(id);
            }
            catch (Exception e)
            {
                if (e is ArgumentException || e is FormatException)
                {
                    return(NotFound());
                }
                throw;
            }

            var pageMask = await _repository.GetPageMaskByIdAsync(pageMaskId);

            if (pageMask == null)
            {
                return(NotFound());
            }

            var model = new MaskPageViewModel()
            {
                PageMask = pageMask,
                Url      = $"{_settings.Value.Hostname}{id}"
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(ProductViewModel model)
        {
            model.ProductId = GuidEncoder.Decode(model.UriKey).ToString();
            var path = string.Format("{0}/{1}", Products_Base_Address,
                                     model.ProductId);

            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    await _appClient.PutAsync(path,
                                              _mapper.Map <ProductDto>(model));

                    //return RedirectToAction("Index");
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                var errMsg = ex.Message;
                return(View("CreateEdit", model));
            }
        }
        public async Task <IActionResult> Edit(AccountViewModel model)
        {
            CancellationToken cancellation = new CancellationToken();

            if (ModelState.IsValid)
            {
                var updateAcct = await _accountRepository.FindAsync(GuidEncoder.Decode(model.UriKey).ToString());

                //updates
                updateAcct.CurrentBalance = model.CurrentBalance;
                //updateAcct.IsBlocked = model.IsBlocked;

                var acc = await _unitOfWorkAccount.UpdateAsync(cancellation, _mapper.Map <Account>(updateAcct));

                var identityUser = await _userManager.FindByIdAsync(acc.Id);

                if (await _userManager.IsInRoleAsync(identityUser, "Bank Admin") || await _userManager.IsInRoleAsync(identityUser, "Bank Manager"))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("UserAccountsByAccountId", new{ id = GuidEncoder.Encode(acc.AccountId) }));
                }
            }


            return(View());
        }
        private async Task PopulateForViewBagAccountTypeToOpenForUserAsync(string userId)
        {
            //var decryptedUserId = GuidEncoder.Decode(userId).ToString();
            //var userAccts = await _accountRepository.FindAccountsByAppUserIdAsync(decryptedUserId);
            //if (userAccts == null || userAccts.Count() <= 0)
            //{

            //}
            ViewBag.Currencies = await GetCurrencsAsync();

            var decryptedAccountTypeId = GuidEncoder.Decode(userId);
            var user = await _appUserRepository.FindAppUserWithAccountAsync(GuidEncoder.Decode(userId).ToString());

            var accTypes = await GetAccountTypesAsync();

            var userAccounts = user.Accounts;

            if (userAccounts.Count > 0)
            {
                var AcctTypeIdsAllowed = accTypes.Select(x => x.AccountTypeId)
                                         .Except(userAccounts.Select(x => x.AccountTypeId));

                ViewBag.AccountTypes = accTypes.Where(x => AcctTypeIdsAllowed.Contains(x.AccountTypeId)).ToList();
            }
            else
            {
                ViewBag.AccountTypes = await GetAccountTypesAsync();
            }
        }
        public async Task <IActionResult> DebitAccount(string id)
        {
            //needs to implement update function

            var decryptedId = GuidEncoder.Decode(id);
            var account     = await _accountRepository.FindAsync(decryptedId.ToString());

            if (!account.IsBlocked)
            {
                ViewBag.AccountTypesLeftForfundTransfer = await _accountTypeRepository.FindAllAccountTypesByAccountTypeIdAsync(account.AccountTypeId);

                ViewBag.OrderByTypes = await GetOrderByTypesAsync();

                ViewBag.TransactionTypes = await GetTransactionTypeAsync();

                var newTransaction = new AccountTransactionViewModel()
                {
                    AccUriKey           = GuidEncoder.Encode(account.AccountId),
                    AppUserUriKey       = GuidEncoder.Encode(account.AppUserId),
                    IdUriKey            = GuidEncoder.Encode(account.Id),
                    AccountTypeIdUriKey = GuidEncoder.Encode(account.AccountTypeId),
                    UiControl           = "Debit"
                };



                return(View("TransferFund", newTransaction));
            }
            //Todo: more informative view
            return(View());
        }
        public async Task <IActionResult> EditRole(string roleId)
        {
            var decryptedId = GuidEncoder.Decode(roleId);
            var role        = await _roleManager.FindByIdAsync(decryptedId.ToString());

            if (role == null)
            {
                ViewBag.ErrorMessage = $"Role with ID = {roleId} cannot be found.";
                return(View("NotFound"));
            }
            var model = new RoleViewModel()
            {
                Id   = role.Id,
                Name = role.Name
            };

            model           = PopulateUriKey(model);
            model.UIControl = "Edit";
            foreach (var user in _userManager.Users)
            {
                if (await _userManager.IsInRoleAsync(user, role.Name))
                {
                    model.RoleUsers.Add(user.FirstName + " " + user.LastName);
                }
            }
            return(View("CreateRole", model));
        }
        public async Task <IActionResult> EditRole(RoleViewModel roleViewModel)
        {
            if (ModelState.IsValid)
            {
                var decryptedId = GuidEncoder.Decode(roleViewModel.UriKey);
                var role        = await _roleManager.FindByIdAsync(decryptedId.ToString());

                if (role == null)
                {
                    ViewBag.ErrorMessage = $"Role with ID = {role.Id} cannnot be found.";
                    return(View("NotFound"));
                }
                role.Name = roleViewModel.Name;
                var updateResult = await _roleManager.UpdateAsync(role);

                if (updateResult.Succeeded)
                {
                    RedirectToAction("Roles");
                }
                foreach (var error in updateResult.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                    return(View(roleViewModel));
                }
            }



            return(View(roleViewModel));
        }
        public async Task <IActionResult> AddOrRemoveUserInRoles(string urikey)
        {
            ViewData["UriKey"] = urikey;

            var decryptedId = GuidEncoder.Decode(urikey);
            var role        = await _roleManager.FindByIdAsync(decryptedId.ToString());

            if (role == null)
            {
                ViewBag.ErrorMessage = $"Role with ID = {urikey} cannnot be found.";
                return(View("NotFound"));
            }
            var models = new List <UserRoleViewModel>();


            //model.UIControl = "Edit";
            foreach (var user in _userManager.Users)
            {
                var userRoleviewModel = new UserRoleViewModel()
                {
                    UserId   = user.Id,
                    UserName = user.UserName
                };

                var fillIsSelected = await _userManager.IsInRoleAsync(user, role.Name) ? userRoleviewModel.IsSelected = true : userRoleviewModel.IsSelected = false;

                models.Add(userRoleviewModel);
            }

            return(View(models));
        }
Exemplo n.º 9
0
        public async Task <ActionResult> Create(AppUserViewModel model)
        {
            var userPath = string.Format("{0}/{1}", User_ByUserIdUri, GuidEncoder.Decode(model.UriKey));
            var user     = _mapper.Map <UserViewModel>(await _apiClient.GetAsync <UserDto>(userPath));


            var path = string.Format("{0}{1}", HttpClientProvider.HttpClient.BaseAddress, BaseUri);

            //model.SubjectId = GuidEncoder.Decode(model.UriKey).ToString();
            model.CreatedDate  = DateTime.UtcNow;
            model.ModifiedDate = DateTime.UtcNow;

            model.GenderId  = GuidEncoder.Decode(model.GenderId).ToString();
            model.CountryId = GuidEncoder.Decode(model.CountryId).ToString();

            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    model.User = user;
                    await _apiClient.PostAsync(path, _mapper.Map <AppUserDto>(model));

                    return(RedirectToAction(nameof(Index)));
                }
                return(View());
            }
            catch (Exception ex)
            {
                var msgError = ex.Message;
                return(View());
            }
        }
Exemplo n.º 10
0
        public async Task <ActionResult> Edit(PricesViewModel model)
        {
            var path = string.Format("{0}/{1}",
                                     Base_Address, GuidEncoder.Decode(model.UriKey));

            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    var pathUpdate = string.Format("{0}/{1}/{2}",
                                                   AlternatePut_Address, GuidEncoder.Decode(model.UriKey), model.Price);


                    //model.PricesId = GuidEncoder.Decode(model.UriKey).ToString();
                    //await _apiClient.PutAsync(path,
                    //    _mapper.Map<PricesDto>(model));

                    await _apiClient.GetAsync <PricesDto>(pathUpdate);

                    return(RedirectToAction(nameof(Index)));
                }

                return(View("CreateEdit", model));
            }
            catch (Exception ex)
            {
                var errMsg = ex.Message;
                return(View("CreateEdit", model));
            }
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Create(AccountViewModel model)
        {
            CancellationToken cancellation = new CancellationToken();

            if (ModelState.IsValid)
            {
                var appUser = await _appUserRepository.FindAsync(GuidEncoder.Decode(model.UriKey).ToString());

                model.Id             = appUser.Id;
                model.AppUserId      = appUser.AppUserId;
                model.OpeningDate    = DateTime.UtcNow;
                model.CurrentBalance = model.OpeningBalance;

                model.PersonalAccountNumber = Guid.NewGuid().ToString();
                model = await _setAccounRate.SetRateAsync(model);

                await _accountRepository.AddAsync(_mapper.Map <Account>(model));

                await _unitOfWorkAccount.CommitAsync(cancellation);

                return(RedirectToAction("Index"));
            }


            return(View());
        }
        public async Task <ActionResult> Edit(AppUserViewModel model)
        {
            model.AppUserId = GuidEncoder.Decode(model.UriKey).ToString();
            model.SubjectId = GuidEncoder.Decode(model.SubjectId).ToString();

            try
            {
                var path = string.Format("{0}", BaseUri);
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    await _apiClient.PutAsync(path, _mapper.Map <AppUserDto>(model));

                    return(RedirectToAction(nameof(Index)));
                }
                await PopulateViewBagsAsync();

                return(View());
            }
            catch (Exception ex)
            {
                var errMsg = ex.Message;
                return(View());
            }
        }
Exemplo n.º 13
0
 // GET: OrderItems/Details/5
 public async Task<ActionResult> Details(string id)
 {
     var path = string.Format("{0}/{1}", Base_Address,
         GuidEncoder.Decode(id));
     var orderItem = _mapper.Map<OrderItemViewModel>(await _apiClient.GetAsync<OrderItemDto>(path));
     orderItem.UriKey = GuidEncoder.Encode(orderItem.OrderItemId);
     return View(orderItem);
 }
Exemplo n.º 14
0
        public async Task <ActionResult> Details(string id)
        {
            var path = string.Format("{0}/{1}", Base_Address,
                                     GuidEncoder.Decode(id));
            var price = _mapper.Map <PricesViewModel>(await _apiClient.GetAsync <PricesDto>(path));

            price.UriKey = GuidEncoder.Encode(price.PricesId);
            return(View(price));
        }
Exemplo n.º 15
0
        // GET: PcoLicencesDetails/Details/5
        public async Task <ActionResult> Details(string id)
        {
            var decodedId = GuidEncoder.Decode(id).ToString();

            var path       = string.Format("{0}/{1}", BaseUri, decodedId);
            var pcoLicence = _mapper.Map <PcoLicenceDetailViewModel>(await _apiClient.GetAsync <PcoLicenceDetailDto>(path));

            return(View(pcoLicence));
        }
Exemplo n.º 16
0
        public async Task <ActionResult> OrderItems(string id)
        {
            var path = string.Format("{0}/{1}", Base_Address,
                                     GuidEncoder.Decode(id));
            var order = _mapper.Map <OrderViewModel>(await _apiClient.GetAsync <OrderDto>(path));

            order.UriKey = GuidEncoder.Encode(order.OrderId);
            return(RedirectToAction("GetOrderItemsByOrderId", nameof(OrderItems), new { id = order.UriKey }));
        }
Exemplo n.º 17
0
        // GET: Products/Details/5
        public ActionResult Details(string id)
        {
            var path = string.Format("{0}{1}/{2}",
                                     HttpClientProvider.HttpClient.BaseAddress, Products_Base_Address,
                                     GuidEncoder.Decode(id));
            var product = _mapper.Map <ProductViewModel>(_appClient.GetAsync <ProductDto>(path));

            product.UriKey = GuidEncoder.Encode(product.ProductId);
            return(View(product));
        }
Exemplo n.º 18
0
        // GET: Products/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            var path = string.Format("{0}/{1}", Products_Base_Address,
                                     GuidEncoder.Decode(id));
            var product = _mapper.Map <ProductViewModel>(await _appClient.GetAsync <ProductDto>(path));

            product.UriKey    = GuidEncoder.Encode(product.ProductId);
            product.UiControl = "Create";
            return(View("CreateEdit", product));
        }
Exemplo n.º 19
0
        public async Task <IActionResult> Delete(AppUserViewModel model)
        {
            var toDeleteAppUser = await _appUserRepository.FindAsync(GuidEncoder.Decode(model.Id).ToString());

            toDeleteAppUser.IsDeleted = true;
            await _unitOfWorkAppUser.UpdateAsync(_cancellationToken, toDeleteAppUser);

            return(RedirectToAction("Index"));

            return(View());
        }
Exemplo n.º 20
0
        public async Task <IActionResult> UnBlockUserApp(string id)
        {
            var decryptedId = GuidEncoder.Decode(id);
            var model       = _mapper.Map <AppUserViewModel>(await _appUserRepository.FindAsync(decryptedId.ToString()));

            model.Gender = await GetGenderAsync(model.GenderId);

            model.Country = await GetCountryAsync(model.CountryId);

            return(View(model));
        }
Exemplo n.º 21
0
        public async Task <IActionResult> AppUserIndex(string id)
        {
            var users = _mapper.Map <IEnumerable <AppUserViewModel> >(
                await _appUserRepository.FindNonBlockedDeleteAppUsersAsync(
                    GuidEncoder.Decode(id).ToString()));

            users = PopulateUriKeyAndAttriburteEncoded(users);
            users = await PopulateCountryIdValueAndGenderIdValue(users);

            return(View(users));
        }
Exemplo n.º 22
0
        // GET: CustomerRelationshipMgms/Details/5
        public async Task <ActionResult> Details(string id)
        {
            var decodedId = GuidEncoder.Decode(id).ToString();

            var path = string.Format("{0}/{1}", BaseUri, decodedId);
            var user = await AppUserAsync(path);

            user.UriKey = GuidEncoder.Encode(user.AppUserId);
            user        = await PopulateCountryGenderIdsValuesAsync(user);

            return(View(user));
        }
Exemplo n.º 23
0
        // GET: CustomerRelationshipMgms/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            var decodedId = GuidEncoder.Decode(id).ToString();

            var path = string.Format("{0}/{1}", BaseUri, decodedId);
            var user = await AppUserAsync(path);

            user.UriKey    = GuidEncoder.Encode(user.AppUserId);
            user.SubjectId = GuidEncoder.Encode(user.SubjectId);
            user.UiControl = "Edit";
            return(View(user));
        }
Exemplo n.º 24
0
        public async Task <IActionResult> Details(string id)
        {
            var decryptedId = GuidEncoder.Decode(id);
            var model       = _mapper.Map <AccountViewModel>(await _accountRepository.FindAsync(decryptedId.ToString()));

            model = await PopulateOnwerNameAsync(model);

            model = PopulateUriKey(model);
            model = await PopulateAccountTypeAsync(model);

            return(View(model));
        }
Exemplo n.º 25
0
        public async Task <ActionResult> Details(string id)
        {
            var path = string.Format("{0}/{1}", Registration_EmailUri, GuidEncoder.Decode(id).ToString());
            var user = await _apiClient.GetAsync <UserDto>(path);

            var appUserPath = string.Format("{0}/{1}", Base_GetAppUserUri, GuidEncoder.Decode(id).ToString());
            var appUser     = _mapper.Map <AppUserViewModel>(await _apiClient.GetAsync <AppUserDto>(appUserPath));

            appUser = await PopulateCountryGenderIdsValuesAsync(appUser);


            return(View(appUser));
        }
Exemplo n.º 26
0
        // GET: Orders/Edit/5
        public async Task <ActionResult> EditAsync(string id)
        {
            var path = string.
                       Format("{0}{1}",
                              HttpClientProvider.HttpClient.BaseAddress, Order_Base_Address,
                              GuidEncoder.Decode(id));
            var orderToEdit = await PopulateUriKeyAsync(
                _mapper.Map <OrderViewModel>(
                    await _apiClient.GetAsync <OrderDto>(path)));

            orderToEdit.UiControl = "EditUi";
            return(View("CreateEdit", orderToEdit));
        }
Exemplo n.º 27
0
        public async Task <ActionResult <AccountViewModel> > UnBlockAccount(string id)
        {
            var decryptedId = GuidEncoder.Decode(id);
            var account     = await _accountRepository.FindAsync(decryptedId.ToString());

            if (!account.IsBlocked)
            {
                account.IsBlocked = true;
                await _unitOfWorkAccount.UpdateAsync(_cancellationToken, account);

                return(RedirectToAction("Details", new { id = id }));
            }
            return(RedirectToAction("Details", new { id = id }));
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Index(string id)
        {
            var path = string.Format("{0}/{1}", Products_Base_Address,
                                     GuidEncoder.Decode(id));
            var product = PopulateUriKey(
                _mapper.Map <ProductViewModel>(
                    await _apiClient.GetAsync <ProductDto>(path)));

            product = await PopulatePricesAsync(product);

            var products = await PopulateAndCreateTypesAsync(product);

            return(View(products));
        }
        // GET: CustomerRelationshipMgms/Create
        public async Task <ActionResult> Create(string id)
        {
            await PopulateViewBagsAsync();

            var path = string.Format("{0}/{1}", User_ByUserIdUri, GuidEncoder.Decode(id));
            var user = await _apiClient.GetAsync <UserDto>(path);

            var newUser = new AppUserViewModel();

            newUser.UriKey      = GuidEncoder.Encode(user.SubjectId);
            newUser.DisplayName = user.Username;
            newUser.UiControl   = "Create";
            return(View("CreateEdit", newUser));
        }
Exemplo n.º 30
0
        public async Task <IActionResult> UserAccounts(string userId)
        {
            var decryptedId = GuidEncoder.Decode(userId);

            var models = _mapper.Map <IEnumerable <AccountViewModel> >(await _accountRepository.FindAccountsByAppUserIdAsync(decryptedId.ToString()));

            models = await PopulateOnwerNamesAsync(models);

            models = PopulateUriKeyWithId(models);

            models = await PopulateAccountTypesAsync(models);

            return(View(models));
        }