public async Task <string> CreatePost(PersonRelationCreateGet PersonRelation) { string usp = "usp_PersonRelationCreatePost @FromPersonId, @ToPersonId, @ValidFrom, @ValidTill, @PersonRelationTypeId, @CreatorId "; var CheckString = await _sqlDataAccess.LoadSingleRecord <string, dynamic>(usp, PersonRelation); return(CheckString); }
public async Task <List <ErrorMessage> > CreatePostCheck(PersonRelationCreateGet PersonRelation) { string usp = "usp_PersonRelationCreatePostCheck @FromPersonId, @ToPersonId, @ValidFrom, @ValidTill, @PersonRelationTypeId, @CreatorId "; var ErrorMessages = await _sqlDataAccess.LoadData <ErrorMessage, dynamic>(usp, PersonRelation); return(ErrorMessages); }
public async Task <IActionResult> Create(PersonRelationCreateGet PersonRelation) { var CurrentUser = await _userManager.GetUserAsync(User); PersonRelation.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 _personRelationProvider.CreatePostCheck(PersonRelation); if (ErrorMessages.Count > 0) { PersonRelation = await CreateAddDropDownBoxes(PersonRelation, CurrentUser.Id); } else { _personRelationProvider.CreatePost(PersonRelation); } PersonRelationCreateGetWithErrorMessages PersonRelationWithErrorMessage = new PersonRelationCreateGetWithErrorMessages { PersonRelation = PersonRelation, ErrorMessages = ErrorMessages }; return(Ok(PersonRelationWithErrorMessage)); } ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id); PersonRelationCreateGetWithErrorMessages PersonRelationWithNoRights = new PersonRelationCreateGetWithErrorMessages { PersonRelation = PersonRelation, ErrorMessages = ErrorMessages }; return(Ok(PersonRelationWithNoRights)); }
public async Task <IActionResult> Create(PersonRelationCreateGet PersonRelation) { var token = HttpContext.Session.GetString("Token"); if (token == null) { return(RedirectToAction("Login", "FrontAuth")); } var PersonRelationCreateGetWithErrorMessage = await _client.PostProtectedAsync <PersonRelationCreateGetWithErrorMessages>($"{_configuration["APIUrl"]}api/PersonRelation/Create", PersonRelation, token); if (PersonRelationCreateGetWithErrorMessage.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 = PersonRelationCreateGetWithErrorMessage.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/PersonRelation/Create", token); //ViewBag.Env = _hostingEnv.EnvironmentName; //ViewBag.ErrorMessages = PersonRelationCreateGetWithErrorMessage.ErrorMessages; return(View(PersonRelationCreateGetWithErrorMessage.PersonRelation)); } return(RedirectToAction("Index", new { id = PersonRelation.FromPersonId })); }
private async Task <PersonRelationCreateGet> CreateAddDropDownBoxes(PersonRelationCreateGet PersonRelation, string UserId) { var PersonRelationTypes = await _personRelationTypeProvider.List(UserId); var Persons = await _personProvider.List(); PersonRelation.PersonRelationTypes = PersonRelationTypes; PersonRelation.Persons = Persons; return(PersonRelation); }
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 PersonRelation = new PersonRelationCreateGet(); PersonRelation = await CreateAddDropDownBoxes(PersonRelation, CurrentUser.Id); return(Ok(PersonRelation)); } return(BadRequest(new { IsSuccess = false, Message = "No rights", })); }