public async Task <IActionResult> Create(ClassificationLevelCreateGet ClassificationLevel)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            ClassificationLevel.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 _classificationLevelProvider.CreatePostCheck(ClassificationLevel);

                if (ErrorMessages.Count > 0)
                {
                    ClassificationLevel = await CreateAddDropDownBoxes(ClassificationLevel, CurrentUser.Id, ClassificationLevel.ClassificationId);
                }
                else
                {
                    _classificationLevelProvider.CreatePost(ClassificationLevel);
                }
                ClassificationLevelCreateGetWithErrorMessages ClassificationLevelWithErrorMessage = new ClassificationLevelCreateGetWithErrorMessages {
                    ClassificationLevel = ClassificationLevel, ErrorMessages = ErrorMessages
                };
                return(Ok(ClassificationLevelWithErrorMessage));
            }
            ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id);

            ClassificationLevelCreateGetWithErrorMessages ClassificationLevelWithNoRights = new ClassificationLevelCreateGetWithErrorMessages {
                ClassificationLevel = ClassificationLevel, ErrorMessages = ErrorMessages
            };

            return(Ok(ClassificationLevelWithNoRights));
        }
Exemple #2
0
        public async Task <IActionResult> Create(ClassificationLevelCreateGet ClassificationLevel)
        {
            var token = HttpContext.Session.GetString("Token");

            if (token == null)
            {
                return(RedirectToAction("Login", "FrontAuth"));
            }
            var ClassificationLevelCreateGetWithErrorMessage = await _client.PostProtectedAsync <ClassificationLevelCreateGetWithErrorMessages>($"{_configuration["APIUrl"]}api/ClassificationLevel/Create", ClassificationLevel, token);

            if (ClassificationLevelCreateGetWithErrorMessage.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 = ClassificationLevelCreateGetWithErrorMessage.ErrorMessages;
                ViewBag.AllStuff       = AllStuff;
                //ViewBag.UITerms = await _client.GetProtectedAsync<List<UITermLanguageCustomizationList>>($"{_configuration["APIUrl"]}api/MVC/ClassificationLevel/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 = ClassificationLevelCreateGetWithErrorMessage.ErrorMessages;
                //ViewBag.Env = _hostingEnv.EnvironmentName;
                return(View(ClassificationLevelCreateGetWithErrorMessage.ClassificationLevel));
            }
            return(RedirectToAction("Index", new { id = ClassificationLevel.ClassificationId }));
        }
        public bool CreatePost(ClassificationLevelCreateGet ClassificationLevel)
        {
            string usp = "usp_classificationLevelCreatePost @ClassificationId,@CodePrefix , @CodeSuffix , @CodeTypeId , @Sequence, @DateLevelId, @OnTheFly, @Alphabetically, @CanLink, @InDropDown, @InMenu,  @Name, @Description, @MenuName, @MouseOver, @UserID";

            _sqlDataAccess.SaveData <ClassificationLevelCreateGet>(usp, ClassificationLevel);
            return(true);
        }
        public async Task <List <ErrorMessage> > CreatePostCheck(ClassificationLevelCreateGet ClassificationLevel)
        {
            string usp           = "usp_ClassificationLevelCreatePostCheck @ClassificationId,@CodePrefix , @CodeSuffix , @CodeTypeId , @Sequence, @DateLevelId, @OnTheFly, @Alphabetically, @CanLink, @InDropDown, @InMenu,  @Name, @Description, @MenuName, @MouseOver, @UserID ";
            var    ErrorMessages = await _sqlDataAccess.LoadData <ErrorMessage, dynamic>(usp, ClassificationLevel);

            return(ErrorMessages);
        }
        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 ClassificationLevel = new ClassificationLevelCreateGet();
                ClassificationLevel = await CreateAddDropDownBoxes(ClassificationLevel, CurrentUser.Id, Id);

                return(Ok(ClassificationLevel));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
        private async Task <ClassificationLevelCreateGet> CreateAddDropDownBoxes(ClassificationLevelCreateGet ClassificationLevel, string UserId, int ClassificationId)
        {
            var ClassificationLevelCreateGetSequences = await _classificationLevelProvider.CreateGetSequence(UserId, ClassificationId);

            var DateLevels = await _dateLevelProvider.List(UserId);

            var UserLanguage = await _masterProvider.UserLanguageUpdateGet(UserId);

            ClassificationLevelCreateGetSequences.Add(new SequenceList {
                Sequence = ClassificationLevelCreateGetSequences.Count + 1, Name = "Add at the end"
            });
            ClassificationLevel.LanguageId   = UserLanguage.LanguageId;
            ClassificationLevel.LanguageName = UserLanguage.Name;
            ClassificationLevel.DateLevels   = DateLevels;
            ClassificationLevel.Sequences    = ClassificationLevelCreateGetSequences;
            ClassificationLevel.CodeTypes    = await _codeTypeProvider.List(UserId);

            ClassificationLevel.ClassificationId = ClassificationId;
            return(ClassificationLevel);
        }