public async Task <IActionResult> CreateAsync(PictureCreateInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } var user = await this.userManager.GetUserAsync(this.User); var imageUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, input.Picture); _ = await this.galleryService.CreateAsync(input.Type, imageUrl, user.Id); return(this.RedirectToAction($"All{input.Type}s")); }
public async Task <IActionResult> Edit(AwardsEditViewModel awardToEdit) { var user = await this.userManager.GetUserAsync(this.User); var imageUrl = string.Empty; if (awardToEdit.Picture != null) { imageUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, awardToEdit.Picture); } string latinName = Transliteration.CyrillicToLatin(awardToEdit.Name, Language.Bulgarian); latinName = latinName.Replace(' ', '-'); await this.awardsService.EditAsync(awardToEdit.Name, latinName, awardToEdit.Date, awardToEdit.Location, awardToEdit.Place, imageUrl, user.Id, awardToEdit.Id); return(this.RedirectToAction("All")); }
public async Task <IActionResult> CreateAsync(AwardsCreateInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } var user = await this.userManager.GetUserAsync(this.User); var imageUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, input.Picture); string latinName = Transliteration.CyrillicToLatin(input.Name, Language.Bulgarian); latinName = latinName.Replace(' ', '-'); _ = await this.awardsService.CreateAsync(input.Name, latinName, input.Date, input.Location, input.Place, imageUrl, user.Id); return(this.RedirectToAction("All")); }
public async Task <IActionResult> CreateAsync(DancesCreateInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } var user = await this.userManager.GetUserAsync(this.User); var imageUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, input.Picture); string latinName = Transliteration.CyrillicToLatin(input.Name, Language.Bulgarian); latinName = latinName.Replace(' ', '-'); _ = await this.dancesService.CreateAsync(input.Name, input.Description, user.Id, imageUrl, latinName, input.FolkloreArea, input.VideoUrl); return(this.RedirectToAction("ByName", new { name = latinName })); }
public async Task <IActionResult> Edit(DanceEditViewModel danceToEdit) { var user = await this.userManager.GetUserAsync(this.User); var imageUrl = string.Empty; if (danceToEdit.Picture != null) { imageUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, danceToEdit.Picture); } string latinName = Transliteration.CyrillicToLatin(danceToEdit.Name, Language.Bulgarian); latinName = latinName.Replace(' ', '-'); await this.dancesService.EditAsync(danceToEdit.Name, danceToEdit.Description, user.Id, imageUrl, latinName, danceToEdit.FolkloreArea, danceToEdit.VideoUrl, danceToEdit.Id); return(this.RedirectToAction("ByName", new { name = latinName })); }
public async Task <IActionResult> CreateAsync(NewsCreateInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } var user = await this.userManager.GetUserAsync(this.User); var imageUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, input.Pictures.First()); string latinTitle = Transliteration.CyrillicToLatin(input.Title, Language.Bulgarian); latinTitle = latinTitle.Replace(' ', '-'); _ = await this.newsService.CreateAsync(input.Title, input.Content, user.Id, imageUrl, latinTitle, input.Author); return(this.RedirectToAction("ByName", new { name = latinTitle })); }
public async Task <IActionResult> Edit(NewsEditViewModel newsPostToEdit) { var user = await this.userManager.GetUserAsync(this.User); var imageUrl = string.Empty; if (newsPostToEdit.Picture != null) { imageUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, newsPostToEdit.Picture); } string latinTitle = Transliteration.CyrillicToLatin(newsPostToEdit.Title, Language.Bulgarian); latinTitle = latinTitle.Replace(' ', '-'); await this.newsService.EditAsync(newsPostToEdit.Title, newsPostToEdit.Content, user.Id, imageUrl, latinTitle, newsPostToEdit.Author, newsPostToEdit.Id); return(this.RedirectToAction("ByName", new { name = latinTitle })); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? this.Url.Content("~/"); this.ExternalLogins = (await this.signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (this.ModelState.IsValid) { var avatarUrl = "https://res.cloudinary.com/sharwinchester/image/upload/v1587592729/Administrative/avatar_pnsyjm.png"; if (this.File != null) { avatarUrl = await CloudinaryExtension.UploadSingleAsync(this.cloudinary, this.File); } var user = new ApplicationUser { UserName = this.Input.Username, Email = this.Input.Email, Description = this.Input.Description, AvatarUrl = avatarUrl, }; var result = await this.userManager.CreateAsync(user, this.Input.Password); if (result.Succeeded) { this.logger.LogInformation("User created a new account with password."); await this.userManager.AddToRoleAsync(user, GlobalConstants.UserRoleName); var code = await this.userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = this.Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code }, protocol: this.Request.Scheme); await this.emailSender.SendEmailAsync(this.Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); if (this.userManager.Options.SignIn.RequireConfirmedAccount) { return(this.RedirectToPage("RegisterConfirmation", new { email = this.Input.Email })); } else { await this.signInManager.SignInAsync(user, isPersistent : false); return(this.LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { this.ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(this.Page()); }