public async Task <IActionResult> Connect(AddConnectedUserDto model) { var users = await _unitOfWork.UserRepo.GetUsersSimpleList(); return(View(new ConnectVM { ConnectedUser = model ?? new AddConnectedUserDto(), Users = users })); }
public async Task <IActionResult> ConnectRedirect([FromForm] AddConnectedUserDto model) { if (!ModelState.IsValid) { return(RedirectToAction("Connect", model)); } var addResult = await _unitOfWork.UserRepo.AddConnectedUser(model); await _unitOfWork.Commit(); return(addResult.Equals(Statuses.Success) ? RedirectToAction("Single", new { id = model.UserId }) : RedirectToAction("Error")); }
public async Task <string> AddConnectedUser(AddConnectedUserDto model) { try { var cu = new ConnectedUser { Type = model.Type, UserId = model.UserId, UserConnectedId = model.ConnectedUserId }; await _context.ConnectedUsers.AddAsync(cu); return(Statuses.Success); } catch { return(Statuses.Error); } }