public async Task <IHttpActionResult> DeleteAsync() { var store = new VotesStore(); await store.ResetAsync().ConfigureAwait(false); return(this.StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostAsync([FromBody] string vote) { var store = new VotesStore(); var added = await store.AddVoteAsync(this.User.Identity.Name, vote).ConfigureAwait(false); if (added) { return(this.StatusCode(HttpStatusCode.NoContent)); } return(this.NotFound()); }
public async Task <IHttpActionResult> GetAsync() { var store = new VotesStore(); var result = new JObject(); foreach (var pair in await store.GetVoteCountByCategoryAsync().ConfigureAwait(false)) { var item = result[pair.Key] = new JObject(); item["votes"] = new JValue(pair.Value); item["uri"] = "img/" + pair.Key + ".png"; } return(this.Ok(result)); }