Example #1
0
        public async Task <string> CreatePost(PersonPositionCreateGet PersonPosition)
        {
            string usp         = "usp_PersonPositionCreatePost @PersonId, @OrganizationId, @PositionId, @UserId ";
            var    CheckString = await _sqlDataAccess.LoadSingleRecord <string, dynamic>(usp, PersonPosition);

            return(CheckString);
        }
Example #2
0
        public async Task <List <ErrorMessage> > CreatePostCheck(PersonPositionCreateGet PersonPosition)
        {
            string usp           = "usp_PersonPositionCreatePostCheck @PersonId, @OrganizationId, @PositionId, @UserId ";
            var    ErrorMessages = await _sqlDataAccess.LoadData <ErrorMessage, dynamic>(usp, PersonPosition);

            return(ErrorMessages);
        }
Example #3
0
        public async Task <IActionResult> Create(PersonPositionCreateGet PersonPosition)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            PersonPosition.UserId = CurrentUser.Id;
            var ErrorMessages = new List <ErrorMessage>();

            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))
            {
                ErrorMessages = await _PersonPositionProvider.CreatePostCheck(PersonPosition);

                if (ErrorMessages.Count > 0)
                {
                    PersonPosition = await CreateAddDropDownBoxes(PersonPosition, CurrentUser.Id, PersonPosition.PersonId);
                }
                else
                {
                    _PersonPositionProvider.CreatePost(PersonPosition);
                }
                PersonPositionCreateGetWithErrorMessages PersonPositionWithErrorMessage = new PersonPositionCreateGetWithErrorMessages {
                    PersonPosition = PersonPosition, ErrorMessages = ErrorMessages
                };
                return(Ok(PersonPositionWithErrorMessage));
            }
            ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id);

            PersonPositionCreateGetWithErrorMessages PersonPositionWithNoRights = new PersonPositionCreateGetWithErrorMessages {
                PersonPosition = PersonPosition, ErrorMessages = ErrorMessages
            };

            return(Ok(PersonPositionWithNoRights));
        }
Example #4
0
        private async Task <PersonPositionCreateGet> CreateAddDropDownBoxes(PersonPositionCreateGet PersonPosition, string UserId, int PersonId)
        {
            var Positions = await _positionProvider.List(UserId);

            var Organizations = await _organizationProvider.List(UserId);

            //PETER TODO --Should exclude maybe some persons and positions
            PersonPosition.Positions     = Positions;
            PersonPosition.Organizations = Organizations;
            PersonPosition.PersonId      = PersonId;
            return(PersonPosition);
        }
Example #5
0
        public async Task <IActionResult> Create(int Id)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))
            {
                var PersonPosition = new PersonPositionCreateGet();
                PersonPosition = await _personPositionProvider.CreateGet(CurrentUser.Id, Id);

                PersonPosition = await CreateAddDropDownBoxes(PersonPosition, CurrentUser.Id, Id);

                return(Ok(PersonPosition));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Example #6
0
        public async Task <IActionResult> Create(PersonPositionCreateGet PersonPosition)
        {
            var token = HttpContext.Session.GetString("Token"); if (token == null)
            {
                return(RedirectToAction("Login", "FrontAuth"));
            }
            var PersonPositionCreateGetWithErrorMessage = await _client.PostProtectedAsync <PersonPositionCreateGetWithErrorMessages>($"{_configuration["APIUrl"]}api/PersonPosition/Create", PersonPosition, token);

            if (PersonPositionCreateGetWithErrorMessage.ErrorMessages.Count > 0)
            {
                var AllStuff = await _loadViewBagModel.ViewBagLoad(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), token, _hostingEnv.EnvironmentName, _configuration, false, 0, "");

                AllStuff.ErrorMessages = PersonPositionCreateGetWithErrorMessage.ErrorMessages;
                ViewBag.AllStuff       = AllStuff;
                //ViewBag.UITerms = await _client.GetProtectedAsync<List<UITermLanguageCustomizationList>>($"{_configuration["APIUrl"]}api/MVC/PersonPosition/Create", token);
                //ViewBag.Favorites = await _client.GetProtectedAsync<List<MVCFavoriteMenu>>($"{_configuration["APIUrl"]}api/MVCFavorite/Menu", token);
                //ViewBag.FavoriteGroupList = await _client.GetProtectedAsync<List<MVCFavoriteGroupList>>($"{_configuration["APIUrl"]}api/MVCFavorite/GroupList", token);

                //ViewBag.ErrorMessages = PersonPositionCreateGetWithErrorMessage.ErrorMessages;
                return(View(PersonPositionCreateGetWithErrorMessage.PersonPosition));
            }

            return(RedirectToAction("Index", new { id = PersonPosition.PersonId }));
        }