public async Task <IActionResult> Edit(int id, [Bind("Id,CreditCardId,OperationCode,TimeStamp,WithdrawalAmount")] UserActionResult actionResult) { if (id != actionResult.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _actionResultService.EditActionResult(actionResult); } catch (InvalidOperationException) { if (!ActionResultExists(actionResult.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(actionResult)); }
private UserActionResult ToUserActionResult(ITry <Unit, SignInError> t) => t.Match( s => UserActionResult.Success(), e => e.Match( SignInError.InvalidCredentials, _ => UserActionResult.Error(UserMessages.InvalidCredentials()), SignInError.NoConnection, _ => UserActionResult.Error(UserMessages.NoConnection()) ) );
public async Task DeleteActionResultById(int id) { UserActionResult userAction = await GetActionResultById(id); if (userAction != null) { await _userActionRepository.DeleteAsync(userAction); } }
public async Task <IActionResult> Create([Bind("Id,CreditCardId,OperationCode,TimeStamp,WithdrawalAmount")] UserActionResult actionResult) { if (ModelState.IsValid) { await _actionResultService.EditActionResult(actionResult); return(RedirectToAction(nameof(Index))); } return(View(actionResult)); }
private UserActionResult ToUserActionResult(ITry <Unit, SignUpError[]> t) => t.Match( s => UserActionResult.Success(), e => e.First().Match( SignUpError.NoConnection, _ => UserActionResult.Error(UserMessages.NoConnection()), SignUpError.InvalidEmail, _ => Email.Invalidate().Pipe(u => UserActionResult.Error()), SignUpError.PasswordTooShort, _ => Password.Invalidate().Pipe(u => UserActionResult.Error()), SignUpError.AccountAlreadyExists, _ => UserActionResult.Error(UserMessages.AccountAlreadyExists()) ) );
private IActionResult GetAuthenticatedActionResult(UserActionResult result) { if (result.User != null) { var token = GetJWTToken(result.User); return(GetActionResult(result, token)); } else { return(GetActionResult(result)); } }
public void BlockAndUnblock() { // TODO - Unblock doesn't seem to actually do anything. Skip this test for now so as not to block the workflow tests. --Kris return; // Block user. UserActionResult res = reddit.Models.Users.BlockUser(new UsersBlockUserInput(name: "RedditDotNetBot")); // Unblock user (returns empty JSON). reddit.Models.Users.Unfriend(new UsersUnfriendInput("RedditDotNetBot", "t2_6vsit", "enemy")); Assert.IsNotNull(res); }
public void Friendship() { // Add a friend. UserActionResult updateRes = reddit.Models.Users.UpdateFriend("RedditDotNetBot"); // Get data on an existing friend. UserActionResult getRes = reddit.Models.Users.GetFriend("RedditDotNetBot"); // It's just not working out. Delete the friend and burn all their stuff. reddit.Models.Users.DeleteFriend("RedditDotNetBot"); Assert.IsNotNull(updateRes); Assert.IsNotNull(updateRes.Name); Assert.IsTrue(updateRes.Name.Equals("RedditDotNetBot")); Assert.IsNotNull(getRes); Assert.IsNotNull(getRes.Name); Assert.IsTrue(getRes.Name.Equals("RedditDotNetBot")); }
private IActionResult GetActionResult(UserActionResult result, string jwt = null) { if (result.Succeeded) { var user = new User { Id = result.User.Id, Name = result.User.UserName, AvatarIconId = result.User.AvatarIconId, DisplayName = result.User.DisplayName }; return(Ok(new { user, jwt })); } else { return(BadRequest(new { message = result.GetErrorsMessage() })); } }
public async Task GetBuIdAsync_ShouldReturnNoAction() { using (var db = new ATMContext(TestOptions.TestDbContextOptions <ATMContext>())) { // Arrange await db.AddRangeAsync(ACTION_RESULTS); await db.SaveChangesAsync(); UserActionResult expectedDbAction = null; int actionId = db.ActionResults.OrderBy(x => x.Id).Last().Id + 1; IRepository <UserActionResult> repository = new DBUserActionResultRepository(db); // Act var result = await repository.GetByIdAsync(actionId); // Assert Assert.Equal(expectedDbAction, result); } }
public async Task EditActionResult(UserActionResult userAction) { await _userActionRepository.EditAsync(userAction); }
public async Task AddActionResult(UserActionResult userAction) { await _userActionRepository.AddAsync(userAction); }
public static UserActionResult ToUserActionResult(this IEnumerable <Exception> exceptions) { var message = exceptions.Select(e => e.Message).Aggregate((s1, s2) => $"{s1}{Environment.NewLine}{s2}"); return(UserActionResult.Error(new UserMessage("Error", message))); }