Esempio n. 1
0
        public IActionResult Index()
        {
            var account          = CurrentAccountProvider.GetCurrentAccount(HttpContext.User);
            var currentUserModel = Mapper.Map <IndexViewModel>(CurrentAccountProvider.GetCurrentUser(HttpContext.User));

            var model = new AddAccessViewModel()
            {
                UsersWithAccess = GetAllUsersWithAccess(account),
                CurrentUser     = currentUserModel
            };

            return(View(model));
        }
Esempio n. 2
0
        public Task <string> AddAccess([FromBody] AddAccessViewModel model)
        {
            AddAccessDomainModel dmodel = new AddAccessDomainModel();

            dmodel.AccessNameID = model.AccessNameID;
            dmodel.RoleId       = model.RoleId;
            dmodel.UpdatedBy    = "190455";
            dmodel.DeleteFlag   = model.DeleteFlag;
            dmodel.updatedDate  = DateTime.Now;

            var result = _iConfigAccessInterface.AddAccess(dmodel);

            return(result);
        }
Esempio n. 3
0
        public IActionResult AddAccessToAccount(AddAccessViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectWithError(ExpenseManagerResource.InvalidInputData));
            }

            var user = GetUserFromEmail(model.Email);

            if (user == null)
            {
                return(RedirectWithError(ExpenseManagerResource.EmailDoesntExist));
            }
            if (user.AccountId != Guid.Empty) // todo this might not be best check
            {
                return(RedirectWithError(ExpenseManagerResource.AlreadyHasAccount));
            }

            var account = CurrentAccountProvider.GetCurrentAccount(HttpContext.User);

            _accountFacade.AttachAccountToUser(user.Id, account.Id, model.AccessType);

            return(RedirectToAction("Index", new { successMessage = ExpenseManagerResource.AccessGranted }));
        }