public IHttpActionResult Delete(SavedSearchInput model) { var result = _savedSearchService.DeleteContent(model); return(Ok(new { success = result.Success, message = result.Message })); }
public IHttpActionResult Post([ModelBinder(typeof(SavedSearchInputPostModelBinder))] SavedSearchInput model) { var result = _savedSearchService.SaveContent(model); return(Ok(new { success = result.Success, message = result.Message })); }
public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) { var result = actionContext.Request.Content.ReadAsStringAsync().Result; var collection = HttpUtility.ParseQueryString(result); var input = new SavedSearchInput { Title = HttpUtility.UrlDecode(collection["Title"]), Url = HttpUtility.UrlDecode(collection["Url"]), AlertEnabled = GetBoolValue(HttpUtility.UrlDecode(collection["AlertEnabled"])) }; // reverse the value passed. bool alert = Regex.IsMatch(result, @"alert-toggle-\d+?=off"); if (alert) { input.AlertEnabled = alert; } bindingContext.Model = input; return(true); }