Ejemplo n.º 1
0
        public async Task <ActionResult> Index()
        {
            var viewModel = new HomeViewModel {
                PersonnelId = UserPersonnelId
            };

            if (User.Identity.IsAuthenticated && viewModel.PersonnelId == 0)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (User.Identity.IsAuthenticated && User.IsSeller())
            {
                var seller = await _sellerBusinessService.RetrieveSellerByPersonnelId(viewModel.PersonnelId);

                if (seller == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
                viewModel.IsSellerApproved = seller.ApprovalStateId == (int)SellerApprovalState.Approved;
            }
            if (User.Identity.IsAuthenticated && User.IsMobileRepairAdmin())
            {
                viewModel.HasMobileRepairPermission = User.IsSuperUser() || await AuthorizationService.AuthorizeAsync((ClaimsPrincipal)User, Policies.Permission.AdministratorMobileRepair.ToString());
            }

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Detail(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var viewModel = new MobileViewModel();

            if (User.IsSuperUserOrAdminOrSeller())
            {
                var seller = await _sellerBusinessService.RetrieveSellerByPersonnelId(UserPersonnelId);

                viewModel.SellerId = seller?.SellerId ?? 0;
            }
            var result = await _mobileBusinessService.RetrieveMobile(id.Value);

            viewModel.MobileName = result.Name;
            viewModel.MobileId   = result.MobileId;
            viewModel.BrandId    = result.BrandId;
            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Profile(bool?profileUpdated)
        {
            var id = UserPersonnelId;

            if (User.IsPersonnel() && !await AuthorizationService.AuthorizeAsync((ClaimsPrincipal)User, id, Policies.Resource.Personnel.ToString()))
            {
                return(HttpForbidden());
            }

            if (id == 0)
            {
                return(RedirectToAction("Login", "Account"));
            }

            var personnel = await _personnelBusinessService.RetrievePersonnel(id);

            if (personnel == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new PersonnelProfileViewModel
            {
                Personnel      = personnel.Entity,
                PersonnelId    = personnel.Entity.PersonnelId,
                ProfileUpdated = profileUpdated ?? false
                                 //Permissions = EgharpayBusinessService.RetrievePersonnelPermissions(isAdmin, UserOrganisationId, UserPersonnelId, id),
                                 //PhotoBytes = EgharpayBusinessService.RetrievePhoto(organisationId, id)
            };

            if (User.IsSeller())
            {
                var seller = await _sellerBusinessService.RetrieveSellerByPersonnelId(personnel.Entity.PersonnelId);

                viewModel.IsSellerApproved = seller.ApprovalStateId == (int)SellerApprovalState.Approved;
            }

            return(View(viewModel));
        }