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

            Organization.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 _organizationProvider.CreatePostCheck(Organization);

                if (ErrorMessages.Count > 0)
                {
                    Organization = await CreateAddDropDownBoxes(Organization, CurrentUser.Id);
                }
                else
                {
                    _organizationProvider.CreatePost(Organization);
                }
                OrganizationCreateGetWithErrorMessages OrganizationWithErrorMessage = new OrganizationCreateGetWithErrorMessages {
                    Organization = Organization, ErrorMessages = ErrorMessages
                };
                return(Ok(OrganizationWithErrorMessage));
            }
            ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id);

            OrganizationCreateGetWithErrorMessages OrganizationWithNoRights = new OrganizationCreateGetWithErrorMessages {
                Organization = Organization, ErrorMessages = ErrorMessages
            };

            return(Ok(OrganizationWithNoRights));
        }
Пример #2
0
        public async Task <string> CreatePost(OrganizationCreateGet Organization)
        {
            string usp         = "usp_OrganizationCreatePost @ParentOrganizationId, @StatusId, @OrganizationTypeID, @Name, @Description, @MenuName, @MouseOver, @UserId";
            var    CheckString = await _sqlDataAccess.LoadSingleRecord <string, dynamic>(usp, Organization);

            return(CheckString);
        }
Пример #3
0
        public async Task <List <ErrorMessage> > CreatePostCheck(OrganizationCreateGet Organization)
        {
            string usp           = "usp_OrganizationCreatePostCheck @ParentOrganizationId, @StatusId, @OrganizationTypeID, @Name, @Description, @MenuName, @MouseOver, @UserId";
            var    ErrorMessages = await _sqlDataAccess.LoadData <ErrorMessage, dynamic>(usp, Organization);

            return(ErrorMessages);
        }
Пример #4
0
        public async Task <IActionResult> Create(OrganizationCreateGet Organization)
        {
            var token = HttpContext.Session.GetString("Token"); if (token == null)
            {
                return(RedirectToAction("Login", "FrontAuth"));
            }
            var OrganizationCreateGetWithErrorMessage = await _client.PostProtectedAsync <OrganizationCreateGetWithErrorMessages>($"{_configuration["APIUrl"]}api/Organization/Create", Organization, token);

            if (OrganizationCreateGetWithErrorMessage.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 = OrganizationCreateGetWithErrorMessage.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/Organization/Create", token);
                //ViewBag.Env = _hostingEnv.EnvironmentName;

                //ViewBag.ErrorMessages = OrganizationCreateGetWithErrorMessage.ErrorMessages;
                return(View(OrganizationCreateGetWithErrorMessage.Organization));
            }

            return(RedirectToAction("Index"));
        }
Пример #5
0
        public async Task <IActionResult> Post(OrganizationCreateGet Organization)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

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

                if (CheckString.Count == 0)
                {
                    _organizationProvider.CreatePost(Organization);
                    return(Ok(Organization));
                }
                return(BadRequest(new
                {
                    IsSuccess = false,
                    Message = CheckString,
                }));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Пример #6
0
        private async Task <OrganizationCreateGet> CreateAddDropDownBoxes(OrganizationCreateGet Organization, string UserId, int?ParentId = null)
        {
            var Statuses = await _masterListProvider.StatusList(UserId);

            var OrganizationTypes = await _organizationTypeProvider.List(UserId);

            var UserLanguage = await _masterProvider.UserLanguageUpdateGet(UserId);

            Organization.LanguageId           = UserLanguage.LanguageId;
            Organization.LanguageName         = UserLanguage.Name;
            Organization.OrganizationTypes    = OrganizationTypes;
            Organization.Statuses             = Statuses;
            Organization.ParentOrganizationId = ParentId;
            return(Organization);
        }
Пример #7
0
        public async Task <IActionResult> Create(int?Id = null)
        {
            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 Organization = new OrganizationCreateGet();
                Organization = await CreateAddDropDownBoxes(Organization, CurrentUser.Id, Id);

                return(Ok(Organization));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Пример #8
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    OrganizationCreateGet  = new OrganizationCreateGet();
                string ParentOrganizationName = "No parent";
                if (Id != 0)
                {
                    ParentOrganizationName = await _organizationProvider.GetOrganizationName(CurrentUser.Id, Id);
                }
//PETER TODO                Have to do something with "No parent"
                var Statuses = await _masterListProvider.StatusList(CurrentUser.Id);

                var OrganizationTypes = await _organizationTypeProvider.ListExternal(CurrentUser.Id);

                if (OrganizationTypes.Count == 0)
                {
                    return(BadRequest(new
                    {
                        IsSuccess = false,
                        Message = "No types",
                    }));
                    //PETER TODO the receiving API should do something with this instead of redirecting
                }
                var UserLanguage = await _masterProvider.UserLanguageUpdateGet(CurrentUser.Id);

                OrganizationCreateGet.LanguageId             = UserLanguage.LanguageId;
                OrganizationCreateGet.ParentOrganizationName = ParentOrganizationName;
                OrganizationCreateGet.LanguageName           = UserLanguage.Name;
                OrganizationCreateGet.OrganizationTypes      = OrganizationTypes;
                OrganizationCreateGet.Statuses             = Statuses;
                OrganizationCreateGet.ParentOrganizationId = Id;
                return(Ok(OrganizationCreateGet));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }