public ActionResult <IEnumerable <string> > Get() { try { return(Krepo.GetKeywords().Select(k => k.Word).ToList()); } catch (Exception e) { logger.Error(e, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public ActionResult <List <FrequencyWrapper <string> > > Get() { try { return(Krepo.GetKeywords().Select(k => new FrequencyWrapper <string>() { Obj = k.Word, Frequency = Krepo.GetRestaurantKeywordJunction().Count(w => w.Word.Equals(k.Word)) }).OrderByDescending(k => k.Frequency).ToList()); } catch (Exception e) { logger.Error(e, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public ActionResult <List <FrequencyWrapper <string> > > Get(string username) { //[Authorize] handles returning 401 if noone is logged in. if (!(User.Identity.Name.Equals(username) || User.IsInRole("admin"))) { return(StatusCode(403));//Forbidden } try { return(Krepo.GetKeywords().Select(k => new FrequencyWrapper <string>() { Obj = k.Word, Frequency = Krepo.GetQueryKeywordJunction().Where(s => s.Query.Username.Equals(User.Identity.Name) && s.Word.Equals(k.Word)).Count() }).OrderByDescending(k => k.Frequency).ToList()); } catch (Exception e) { logger.Error(e, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }