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)); }
public IHttpActionResult Get() { var connectionString = File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Data/azurestorage.secret")); var store = new VotesStore(connectionString); var result = new JObject(); foreach(var pair in store.GetVoteCountByCategory()) { var item = result[pair.Key] = new JObject(); item["votes"] = new JValue(pair.Value); item["uri"] = "img/" + pair.Key + ".png"; } return this.Ok(result); }