public async Task <IActionResult> Create([Bind("Id,UserId,ProfilePicture,IsDefault")] UserPicture userPicture, IFormFile ProfilePicture) { string sImagePath = GetImagePath(UserId); string sImageThumbnailPath = GetThumbnailImagePath(UserId); var path = Path.Combine(sImagePath, ProfilePicture.FileName); var thumbpath = Path.Combine(sImageThumbnailPath, ProfilePicture.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await ProfilePicture.CopyToAsync(stream); } Crop(200, 200, ProfilePicture.OpenReadStream(), thumbpath); userPicture.UserId = UserId; userPicture.ProfilePicture = ProfilePicture.FileName; _context.Add(userPicture); if (ProfilePicture == null || ProfilePicture.Length == 0) { return(Content("file not selected")); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("Id,Name,EmailAddress,PhoneNumber,Gender,DateOfBirth,RegistrationDate,Password")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("Id,UserId,ProfileId,Message,SentDate")] UserMessage userMessage) { if (ModelState.IsValid) { _context.Add(userMessage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userMessage)); }
public async Task <IActionResult> Create([Bind("Id,UserId,ContactName,RelationShip,ContactNumber,ContactAddress")] UserContact userContact) { if (ModelState.IsValid) { userContact.UserId = UserId; _context.Add(userContact); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userContact)); }