Пример #1
0
        public async Task <IActionResult> Create(ProjectCreateGet Project)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            Project.UserId = CurrentUser.Id;
            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))
            {
                var CheckString = await _projectProvider.CreatePostCheck(Project);

                if (CheckString.Count == 0)
                {
                    _projectProvider.CreatePost(Project);
                    return(Ok(Project));
                }
                return(BadRequest(new
                {
                    IsSuccess = false,
                    Message = CheckString,

                    //PETER TODO Not sure if the issue is here. But need to check if all is filled in well and then give feedback to front mvc
                }));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Пример #2
0
        public async Task <IActionResult> Create(ProjectCreateGet Project)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            Project.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 _projectProvider.CreatePostCheck(Project);

                if (ErrorMessages.Count > 0)
                {
                    Project = await CreateAddDropDownBoxes(Project, CurrentUser.Id);
                }
                else
                {
                    _projectProvider.CreatePost(Project);
                }
                ProjectCreateGetWithErrorMessages ProjectWithErrorMessage = new ProjectCreateGetWithErrorMessages {
                    Project = Project, ErrorMessages = ErrorMessages
                };
                return(Ok(ProjectWithErrorMessage));
            }
            ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id);

            ProjectCreateGetWithErrorMessages ProjectWithNoRights = new ProjectCreateGetWithErrorMessages {
                Project = Project, ErrorMessages = ErrorMessages
            };

            return(Ok(ProjectWithNoRights));
        }