public async Task <IActionResult> Edit(int id, [Bind("Id,Displayname,Firstname,Lastname,Bio,UserAccountId")] BuildUser buildUser) { if (id != buildUser.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(buildUser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuildUserExists(buildUser.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(ProfileInfo))); } return(View(buildUser)); }
public async Task <NetWorthDetailModel> Handle(GetNetWorthQuery request, CancellationToken cancellationToken) { User entity = await BuildUser.BuildFromContext(_context, request.Id); return(new NetWorthDetailModel { UserID = request.Id, DateToNetWorthDict = entity.GetFutureNetWorthByMonth(_dateTime.Now, request.FutureDate) }); }
public IActionResult ProfileInfo() { string userID = _userManager.GetUserId(User); BuildUser profile = _context.BuildUser.FirstOrDefault(p => p.UserAccountId == userID); if (profile == null) { return(RedirectToAction("Create")); } return(View(profile)); }
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 IActionResult Inbox() { BuildUser profile = _context.BuildUser.FirstOrDefault(id => id.UserAccountId == _userManager.GetUserId(User)); InboxViewModel inbox = new InboxViewModel(); inbox.mailMessages = _context.MailMessages.Where(to => to.ToProfileId == profile.Id).ToList(); List <BuildUser> fromList = new List <BuildUser>(); foreach (var msg in inbox.mailMessages) { fromList.Add(_context.BuildUser.FirstOrDefault(from => from.Id == msg.FromProfileId)); } inbox.fromProfile = fromList; return(View(inbox)); }
public async Task <IActionResult> Create([Bind("Id,Displayname,Firstname,Lastname,Bio,UserAccountId")] 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)); }
public async Task <UserDetailModel> Handle(GetUserDetailQuery request, CancellationToken cancellationToken) { User entity = await BuildUser.BuildFromContext(_context, request.Id); return(_mapper.Map <UserDetailModel>(entity)); }