public async Task <IActionResult> SignupAsYuTuber(string link) { var channelData = await facade.GetChannelDataAsync(link); var userId = (this.User.Identity as ClaimsIdentity).FindFirst(ClaimTypes.NameIdentifier).Value; var yuTuber = new YuTuberViewModel() { AppUserId = userId, ChannelLink = link, ChannelName = channelData.Title, SubscribersCount = (ulong)channelData.SubsCount, VideoCount = (ulong)channelData.VideoCount, ThumbnailUrl = channelData.ThumbnailUrl, ChannelId = channelData.ChannelId, Country = channelData.Country }; var categories = from c in await repo.GetCategories() select new SelectListItem { Text = c.Name, Value = c.Id.ToString() }; ViewBag.Categories = await repo.GetCategoriesAsSelectList(); return(View(yuTuber)); }
public async Task <IActionResult> EditYourProfilePost(YuTuberViewModel model) { if (ModelState.IsValid) { var yuTuber = mapper.Map <YuTuber>(model); await yuRepo.UpdateYuTuber(yuTuber); return(RedirectToAction(nameof(YourProfile), new { username = yuTuber.ChannelId })); } ViewBag.Categories = await repo.GetCategoriesAsSelectList(); return(View(model)); }
public async Task <IActionResult> FinishSignup(YuTuberViewModel yuTuberViewModel) { if (ModelState.IsValid) { var yuTubers = mapper.Map <YuTuber>(yuTuberViewModel); var context = new System.ComponentModel.DataAnnotations.ValidationContext(yuTubers); ICollection <ValidationResult> results = new List <ValidationResult>(); var isValid = Validator.TryValidateObject(yuTubers, context, results); yuTubers.Category = null; if (isValid) { await yuRepo.CreateYuTuber(yuTubers); return(RedirectToAction(nameof(YourProfile), new { username = yuTubers.ChannelId })); } else { return(View("ExceptionPage", string.Join(",", results))); } } ViewBag.Categories = await repo.GetCategoriesAsSelectList(); return(View("SignupAsYuTuber", yuTuberViewModel)); }