public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var user = await _userManager.GetUserAsync(User); var userId = _userManager.GetUserId(User); var userName = user.UserName; var reason = Input.ReasonPlatformRequest; if (reason == null) { reason = "Wil platform aanmaken voor mijn organisatie aub."; } BL.Domain.User.PlatformRequest platformRequest = new BL.Domain.User.PlatformRequest() { Date = DateTime.Now, Reason = reason, UserId = userId, OrganisationName = userName }; _platformRequestManager.CreatePlatformRequest(platformRequest); return(RedirectToPage()); }
public async Task <IActionResult> Createplatformrequest([FromForm] PlatformViewModel platformViewModel) { if (ModelState.IsValid) { var stylesheet = new ColorScheme() { SocialBarColor = platformViewModel.SocialBarColor, NavBarColor = platformViewModel.NavbarColor, BannerColor = platformViewModel.BannerColor, ButtonColor = platformViewModel.ButtonColor, ButtonTextColor = platformViewModel.ButtonTextColor, TextColor = platformViewModel.TextColor, BodyColor = platformViewModel.BodyColor, }; var logoFileName = Util.Util.GenerateDataStoreObjectName(platformViewModel.Name); var logoImageObj = new Media() { Name = logoFileName, Url = await _fileUploader.UploadFile(logoFileName, "platform-logos", platformViewModel.Logo), }; var bannerFileName = Util.Util.GenerateDataStoreObjectName(platformViewModel.Name); var bannerImageObj = new Media() { Name = bannerFileName, Url = await _fileUploader.UploadFile(bannerFileName, "platform-banners", platformViewModel.Banner), }; var platform = new Platform() { Name = platformViewModel.Name, Tenant = platformViewModel.Tenant, Logo = logoImageObj, Banner = bannerImageObj, Description = platformViewModel.Description, ColorScheme = stylesheet, }; var user = _userManager.GetUserAsync(User).Result; var platformRequest = new PlatformRequest() { Accept = false, Date = DateTime.Now, OrganisationName = user.FirmName, Reason = platformViewModel.PlatformReason, Treated = false, UserId = user.Id, Platform = platform }; _platformRequestManager.CreatePlatformRequest(platformRequest); // _platformManager.AddPlatform(platform); _unitOfWorkManager.Save(); return(Ok()); } return(StatusCode(400)); }