public async Task <bool> CreateUserImgAsync(UserImgDb userImg) { await context.AddAsync(userImg); await context.SaveChangesAsync(); return(await Task.FromResult(true)); }
public async Task <IActionResult> _RegisterSection(RegiserModel model) { if (ModelState.IsValid) { //-------------- Save Image to Database //UserImgDb userImg = new UserImgDb(); //using (var memoryStream = new MemoryStream()) //{ // await model.ImgPic.CopyToAsync(memoryStream); // userImg.UserImg = memoryStream.ToArray(); //} //-------------- Save Image to Image Folder in the Web Hosting Enivornment string uniqueFileName = UploadedFile(model); UserImgDb userImg = new UserImgDb { UserImg = uniqueFileName }; bool result = await _repo.CreateUserImgAsync(userImg); if (result) { UserDb user = new UserDb { UserName = model.AccountName, UserEmail = model.AccountEmail, UserAddress = model.AccountAddress, UserCity = model.AccountCity, UserCountry = model.AccountCountry, UserDescription = model.AccountDescription, ImageId = userImg.ImageId }; if (model.IsShop) { user.IsShop = true; } var identityResult = await userManager.CreateAsync(user, model.AccountPassword); if (identityResult.Succeeded) { ViewBag.Set = "You are all Set to LogIn"; // return Request. // return RedirectToAction("Index", "Account"); } else { foreach (IdentityError error in identityResult.Errors) { ModelState.AddModelError("", error.Description); } } } } //return PartialView(""model); // return View("AccountManagement", model); return(View("AccountManagement", new AccountPort { RegiserModel = model })); //return View(model); }