public HttpResponseMessage Get(string id) { try { var item = BlogRollItem.GetBlogRollItem(Guid.Parse(id)); if (item == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } var result = new BlogRollRowItem { IsChecked = false, Id = item.Id, Title = item.Title, Description = item.Description, BlogUrl = item.BlogUrl.ToString(), FeedUrl = item.FeedUrl.ToString(), Xfn = item.Xfn }; return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (UnauthorizedAccessException) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage Update([FromBody] BlogRollRowItem item) { try { var br = BlogRollItem.GetBlogRollItem(item.Id); if (br == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } br.Title = item.Title; br.Description = item.Description; br.BlogUrl = new Uri(item.BlogUrl); br.FeedUrl = new Uri(item.FeedUrl); br.Xfn = item.Xfn.TrimEnd(); br.Save(); Resort(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (UnauthorizedAccessException) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }
public HttpResponseMessage Post(BlogRollRowItem item) { try { BlogRollItem br = new BlogRollItem(); br.Title = item.Title.Replace(@"\", "'"); br.Description = item.Description; br.BlogUrl = new Uri(getUrl(item.BlogUrl)); br.FeedUrl = new Uri(getUrl(item.FeedUrl)); br.Xfn = item.Xfn.TrimEnd(); int largestSortIndex = -1; foreach (BlogRollItem brExisting in BlogRollItem.BlogRolls) { if (brExisting.SortIndex > largestSortIndex) largestSortIndex = brExisting.SortIndex; } br.SortIndex = largestSortIndex + 1; br.Save(); if (br == null) return Request.CreateResponse(HttpStatusCode.NotFound); return Request.CreateResponse(HttpStatusCode.Created, br); } catch (UnauthorizedAccessException) { return Request.CreateResponse(HttpStatusCode.Unauthorized, Resources.labels.notAuthorized); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } }
public HttpResponseMessage Get(string id) { try { var item = BlogRollItem.GetBlogRollItem(Guid.Parse(id)); if (item == null) return Request.CreateResponse(HttpStatusCode.NotFound); var result = new BlogRollRowItem { IsChecked = false, Id = item.Id, Title = item.Title, Description = item.Description, BlogUrl = item.BlogUrl.ToString(), FeedUrl = item.FeedUrl.ToString(), Xfn = item.Xfn }; return Request.CreateResponse(HttpStatusCode.OK, result); } catch (UnauthorizedAccessException) { return Request.CreateResponse(HttpStatusCode.Unauthorized); } catch (Exception) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } }
public HttpResponseMessage Update([FromBody] BlogRollRowItem item) { var br = BlogRollItem.GetBlogRollItem(item.Id); if (br == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } br.Title = item.Title; br.Description = item.Description; br.BlogUrl = new Uri(item.BlogUrl); br.FeedUrl = new Uri(item.FeedUrl); br.Xfn = item.Xfn.TrimEnd(); br.Save(); Resort(); return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage Get(string id) { var item = BlogRollItem.GetBlogRollItem(Guid.Parse(id)); if (item == null) return Request.CreateResponse(HttpStatusCode.NotFound); var result = new BlogRollRowItem { IsChecked = false, Id = item.Id, Title = item.Title, Description = item.Description, BlogUrl = item.BlogUrl.ToString(), FeedUrl = item.FeedUrl.ToString(), Xfn = item.Xfn }; return Request.CreateResponse(HttpStatusCode.OK, result); }
public HttpResponseMessage Post(BlogRollRowItem item) { BlogRollItem br = new BlogRollItem(); br.Title = item.Title.Replace(@"\", "'"); br.Description = item.Description; br.BlogUrl = new Uri(getUrl(item.BlogUrl)); br.FeedUrl = new Uri(getUrl(item.FeedUrl)); br.Xfn = item.Xfn.TrimEnd(); int largestSortIndex = -1; foreach (BlogRollItem brExisting in BlogRollItem.BlogRolls) { if (brExisting.SortIndex > largestSortIndex) largestSortIndex = brExisting.SortIndex; } br.SortIndex = largestSortIndex + 1; br.Save(); return Request.CreateResponse(HttpStatusCode.Created, br); }
public HttpResponseMessage Get(string id) { var item = BlogRollItem.GetBlogRollItem(Guid.Parse(id)); if (item == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } var result = new BlogRollRowItem { IsChecked = false, Id = item.Id, Title = item.Title, Description = item.Description, BlogUrl = item.BlogUrl.ToString(), FeedUrl = item.FeedUrl.ToString(), Xfn = item.Xfn }; return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage Post(BlogRollRowItem item) { try { BlogRollItem br = new BlogRollItem(); br.Title = item.Title.Replace(@"\", "'"); br.Description = item.Description; br.BlogUrl = new Uri(getUrl(item.BlogUrl)); br.FeedUrl = new Uri(getUrl(item.FeedUrl)); br.Xfn = item.Xfn.TrimEnd(); int largestSortIndex = -1; foreach (BlogRollItem brExisting in BlogRollItem.BlogRolls) { if (brExisting.SortIndex > largestSortIndex) { largestSortIndex = brExisting.SortIndex; } } br.SortIndex = largestSortIndex + 1; br.Save(); if (br == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.Created, br)); } catch (UnauthorizedAccessException) { return(Request.CreateResponse(HttpStatusCode.Unauthorized, Resources.labels.notAuthorized)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Post(BlogRollRowItem item) { BlogRollItem br = new BlogRollItem(); br.Title = item.Title.Replace(@"\", "'"); br.Description = item.Description; br.BlogUrl = new Uri(getUrl(item.BlogUrl)); br.FeedUrl = new Uri(getUrl(item.FeedUrl)); br.Xfn = item.Xfn.TrimEnd(); int largestSortIndex = -1; foreach (BlogRollItem brExisting in BlogRollItem.BlogRolls) { if (brExisting.SortIndex > largestSortIndex) { largestSortIndex = brExisting.SortIndex; } } br.SortIndex = largestSortIndex + 1; br.Save(); return(Request.CreateResponse(HttpStatusCode.Created, br)); }