Exemple #1
0
        public async Task <string> CreatePost(PersonCreateGet Person)
        {
            string usp         = "usp_PersonCreatePost @Salutation, @FirstName, @MiddleName, @LastName, @PersonalTitle, @Suffix, @NickName, @FirstNameLocal, @MiddleNameLocal, @LastNameLocal, @GenderId, @Birthdate, @DefaultOrganizationId, @SelectedUserId, @UserId ";
            var    CheckString = await _sqlDataAccess.LoadSingleRecord <string, dynamic>(usp, Person);

            return(CheckString);
        }
Exemple #2
0
        public async Task <List <ErrorMessage> > CreatePostCheck(PersonCreateGet Person)
        {
            string usp           = "usp_PersonCreatePostCheck @Salutation, @FirstName, @MiddleName, @LastName, @PersonalTitle, @Suffix, @NickName, @FirstNameLocal, @MiddleNameLocal, @LastNameLocal, @GenderId, @Birthdate, @DefaultOrganizationId, @SelectedUserId, @UserId ";
            var    ErrorMessages = await _sqlDataAccess.LoadData <ErrorMessage, dynamic>(usp, Person);

            return(ErrorMessages);
        }
        public async Task <IActionResult> Create(PersonCreateGet Person)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            Person.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 _personProvider.CreatePostCheck(Person);

                if (ErrorMessages.Count > 0)
                {
                    Person = await CreateAddDropDownBoxes(Person, CurrentUser.Id);
                }
                else
                {
                    _personProvider.CreatePost(Person);
                }
                PersonCreateGetWithErrorMessages PersonWithErrorMessage = new PersonCreateGetWithErrorMessages {
                    Person = Person, ErrorMessages = ErrorMessages
                };
                return(Ok(PersonWithErrorMessage));
            }
            ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id);

            PersonCreateGetWithErrorMessages PersonWithNoRights = new PersonCreateGetWithErrorMessages {
                Person = Person, ErrorMessages = ErrorMessages
            };

            return(Ok(PersonWithNoRights));
        }
Exemple #4
0
        public async Task <IActionResult> Create(PersonCreateGet Person)
        {
            var token = HttpContext.Session.GetString("Token"); if (token == null)
            {
                return(RedirectToAction("Login", "FrontAuth"));
            }

            var PersonCreateGetWithErrorMessage = await _client.PostProtectedAsync <PersonCreateGetWithErrorMessages>($"{_configuration["APIUrl"]}api/Person/Create", Person, token);

            if (PersonCreateGetWithErrorMessage.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 = PersonCreateGetWithErrorMessage.ErrorMessages;
                ViewBag.AllStuff       = AllStuff;
                //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.UITerms = await _client.GetProtectedAsync<List<UITermLanguageCustomizationList>>($"{_configuration["APIUrl"]}api/MVC/Person/Create", token);
                //ViewBag.Env = _hostingEnv.EnvironmentName;

                //ViewBag.ErrorMessages = PersonCreateGetWithErrorMessage.ErrorMessages;
                return(View(PersonCreateGetWithErrorMessage.Person));
            }


            return(RedirectToAction("Index"));
        }
        private async Task <PersonCreateGet> CreateAddDropDownBoxes(PersonCreateGet Person, string UserId)
        {
            var Genders = await _genderProvider.List(UserId);

            var Organizations = await _organizationProvider.List(UserId);

            Person.Genders       = Genders;
            Person.Organizations = Organizations;
            Person.Users         = await _personProvider.CreateGetUsers();

            return(Person);
        }
        public async Task <IActionResult> Create()
        {
            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 Person = new PersonCreateGet();
                Person = await CreateAddDropDownBoxes(Person, CurrentUser.Id);

                return(Ok(Person));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }