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 Delete(Topic topic, Guid id) => Handle(() => { using (var client = new FlashcardsHttpClient()) { return(client.Delete(RestUrl(topic, id))); } });
public bool Edit(Topic topic, Category category) => Handle(() => { using (var client = new FlashcardsHttpClient()) { return(client.Put(RestUrl(topic), category)); } });
public bool Edit(Topic topic, string category, string deck, Card card) => Handle(() => { using (var client = new FlashcardsHttpClient()) { return(client.Put(RestUrl(topic, category, deck), card)); } });
public bool Add(Topic topic, string category, Deck deck) => Handle(() => { using (var client = new FlashcardsHttpClient()) { return(client.Post(RestUrl(topic, category), deck)); } });
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); } } }