public IActionResult Send([Bind("MessageTitle, MessageText")] MailMessages mail, int toProfileId) { BuildUser fromUser = _context.BuildUser.FirstOrDefault(p => p.UserAccountId == _userManager.GetUserId(User)); mail.FromProfileId = fromUser.Id; mail.IsRead = false; mail.FromProfile = fromUser; mail.ToProfileId = toProfileId; _context.Add(mail); _context.SaveChanges(); return(RedirectToAction("Browse", "BuildUsers")); }
public async Task <IActionResult> Create([Bind("Id,Buildname,BuildContent,BuildTime,BuilderNum,WorldSeed,BuildPhoto,BuildDate")] BuildTable buildTable, IFormFile FilePhoto) { if (FilePhoto.Length > 0) { string buildPhoto = _webroot.WebRootPath + "\\buildPhotos\\"; var fileName = Path.GetFileName(FilePhoto.FileName); using (var stream = System.IO.File.Create(buildPhoto + fileName)) { await FilePhoto.CopyToAsync(stream); buildTable.BuildPhoto = fileName; } } if (ModelState.IsValid) { _context.Add(buildTable); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } return(View(buildTable)); }
public async Task <IActionResult> Create([Bind("Id,Displayname,Firstname,Lastname,Bio,UserAccountId,PhotoPath")] BuildUser buildUser, IFormFile FilePhoto) { if (FilePhoto.Length > 0) { string photoPath = _webroot.WebRootPath + "\\userPhotos\\"; var fileName = Path.GetFileName(FilePhoto.FileName); using (var stream = System.IO.File.Create(photoPath + fileName)) { await FilePhoto.CopyToAsync(stream); buildUser.PhotoPath = fileName; } } if (ModelState.IsValid) { _context.Add(buildUser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ProfileInfo))); } return(View(buildUser)); }