public async Task <IActionResult> Create(PersonAddressCreateGet PersonAddress) { var CurrentUser = await _userManager.GetUserAsync(User); PersonAddress.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 _personAddressProvider.CreatePostCheck(PersonAddress); if (ErrorMessages.Count > 0) { PersonAddress = await CreateAddDropDownBoxes(PersonAddress, CurrentUser.Id, PersonAddress.PersonId); } else { _personAddressProvider.CreatePost(PersonAddress); } PersonAddressCreateGetWithErrorMessages PersonAddressWithErrorMessage = new PersonAddressCreateGetWithErrorMessages { PersonAddress = PersonAddress, ErrorMessages = ErrorMessages }; return(Ok(PersonAddressWithErrorMessage)); } ErrorMessages = await _checkProvider.NoRightsMessage(CurrentUser.Id); PersonAddressCreateGetWithErrorMessages PersonAddressWithNoRights = new PersonAddressCreateGetWithErrorMessages { PersonAddress = PersonAddress, ErrorMessages = ErrorMessages }; return(Ok(PersonAddressWithNoRights)); }
public async Task <IActionResult> Create(PersonAddressCreateGet PersonAddress) { var token = HttpContext.Session.GetString("Token"); if (token == null) { return(RedirectToAction("Login", "FrontAuth")); } var PersonAddressCreateGetWithErrorMessage = await _client.PostProtectedAsync <PersonAddressCreateGetWithErrorMessages>($"{_configuration["APIUrl"]}api/PersonAddress/Create", PersonAddress, token); if (PersonAddressCreateGetWithErrorMessage.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 = PersonAddressCreateGetWithErrorMessage.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/PersonAddress/Create", token); //ViewBag.Env = _hostingEnv.EnvironmentName; //ViewBag.ErrorMessages = PersonAddressCreateGetWithErrorMessage.ErrorMessages; return(View(PersonAddressCreateGetWithErrorMessage.PersonAddress)); } return(RedirectToAction("Index", new { id = PersonAddress.PersonId })); }
public async Task <string> CreatePost(PersonAddressCreateGet PersonAddress) { string usp = "usp_PersonAddressCreatePost @PersonId, @AddressTypeId, @AttnName, @Address1, @Address2, @HouseNumber, @HouseNumberExt, @City, @PostalCode, @PostalCodeExt, @CountryId, @ProvinceState, @County, @UserId "; var CheckString = await _sqlDataAccess.LoadSingleRecord <string, dynamic>(usp, PersonAddress); return(CheckString); }
public async Task <List <ErrorMessage> > CreatePostCheck(PersonAddressCreateGet PersonAddress) { string usp = "usp_PersonAddressCreatePostCheck @PersonId, @AddressTypeId, @AttnName, @Address1, @Address2, @HouseNumber, @HouseNumberExt, @City, @PostalCode, @PostalCodeExt, @CountryId, @ProvinceState, @County, @UserId "; var ErrorMessages = await _sqlDataAccess.LoadData <ErrorMessage, dynamic>(usp, PersonAddress); return(ErrorMessages); }
private async Task <PersonAddressCreateGet> CreateAddDropDownBoxes(PersonAddressCreateGet PersonAddress, string UserId, int PersonId) { var AddressTypes = await _addressTypeProvider.List(UserId); var Countries = await _masterListProvider.CountryList(UserId); PersonAddress.AddressTypes = AddressTypes; PersonAddress.Countries = Countries; PersonAddress.PersonId = PersonId; return(PersonAddress); }
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 PersonAddress = new PersonAddressCreateGet(); PersonAddress = await CreateAddDropDownBoxes(PersonAddress, CurrentUser.Id, Id); return(Ok(PersonAddress)); } return(BadRequest(new { IsSuccess = false, Message = "No rights", })); }