public ApiResponse <SessionState> ApplySessionCard(Topic topic, string category, string deck, ApplySessionCardCommand command) { using (var client = new FlashcardsHttpClient()) { var url = $"/topics/{topic}/categories/{category}/decks/{deck}/sessions"; return(client.Post <SessionState>(url, command)); } }
public bool Add(Topic topic, string category, string deck, Card card) => Handle(() => { using (var client = new FlashcardsHttpClient()) { return(client.Post(RestUrl(topic, category, deck), card)); } });
public bool Add(Topic topic, Category category) => Handle(() => { using (var client = new FlashcardsHttpClient()) { return(client.Post(RestUrl(topic), category)); } });
public bool Auth(string email, string password) { if (email.IsEmpty()) { FlashcardsMessageBox.Error("Email can't be empty."); return(false); } else if (password.IsEmpty()) { FlashcardsMessageBox.Error("Password can't be empty."); return(false); } using (var client = new FlashcardsHttpClient()) { var body = new { Email = email, Password = password }; var authResponse = client.Post <JwtToken>(@"/auth", body); if (authResponse.IsSuccess) { Session.Jwt = authResponse.Result; client.LoadToken(); var userResponse = client.Get <User>($@"/users/{email}"); if (userResponse.IsSuccess) { Session.User = userResponse.Result; Session.User.Password = password; } return(true); } else { FlashcardsMessageBox.Error(authResponse.ErrorMessage); return(false); } } }