예제 #1
0
        public async Task <IActionResult> Update(ClassificationUpdateGet Classification)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))
            {
                Classification.UserId = CurrentUser.Id;
                //var CheckString = await _classificationProvider.UpdatePostCheck(Classification);
                //if (CheckString.Length == 0)
                //{
                _classificationProvider.UpdatePost(Classification);
                return(Ok(Classification));

                //}
                return(BadRequest(new
                {
                    IsSuccess = false,
                    //Message = CheckString,
                }));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
예제 #2
0
        public async Task <IActionResult> Update(ClassificationUpdateGet Classification)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            Classification.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 _classificationProvider.UpdatePostCheck(Classification);

                if (ErrorMessages.Count > 0)
                {
                    Classification = await UpdateAddDropDownBoxes(Classification, CurrentUser.Id);
                }
                else
                {
                    await _classificationProvider.UpdatePost(Classification);
                }
                ClassificationUpdateGetWithErrorMessages ClassificationWithErrorMessage = new ClassificationUpdateGetWithErrorMessages {
                    Classification = Classification, ErrorMessages = ErrorMessages
                };
                return(Ok(ClassificationWithErrorMessage));
            }
            ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id);

            ClassificationUpdateGetWithErrorMessages ClassificationWithNoRights = new ClassificationUpdateGetWithErrorMessages {
                Classification = Classification, ErrorMessages = ErrorMessages
            };

            return(Ok(ClassificationWithNoRights));
        }