Example #1
0
        public async Task <IActionResult> Create(PropertyCreateGet Property)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            Property.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 _propertyProvider.CreatePostCheck(Property);

                if (ErrorMessages.Count > 0)
                {
                    Property = await CreateAddDropDownBoxes(Property, CurrentUser.Id);
                }
                else
                {
                    _propertyProvider.CreatePost(Property);
                }
                PropertyCreateGetWithErrorMessages PropertyWithErrorMessage = new PropertyCreateGetWithErrorMessages {
                    Property = Property, ErrorMessages = ErrorMessages
                };
                return(Ok(PropertyWithErrorMessage));
            }
            ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id);

            PropertyCreateGetWithErrorMessages PropertyWithNoRights = new PropertyCreateGetWithErrorMessages {
                Property = Property, ErrorMessages = ErrorMessages
            };

            return(Ok(PropertyWithNoRights));
        }