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); }
private void AddBlog() { BlogRollItem br = new BlogRollItem(); br.Title = txtTitle.Text.Replace(@"\", "'"); br.Description = txtDescription.Text; br.BlogUrl = new Uri(getUrl(txtWebUrl.Text)); br.FeedUrl = new Uri(getUrl(txtFeedUrl.Text)); br.Xfn = string.Empty; foreach (ListItem item in cblXfn.Items) { if (item.Selected) br.Xfn += item.Text + " "; } if (br.Xfn.Length > 0) { br.Xfn = br.Xfn.Substring(0, br.Xfn.Length - 1); } int largestSortIndex = -1; foreach (BlogRollItem brExisting in BlogRollItem.BlogRolls) { if (brExisting.SortIndex > largestSortIndex) largestSortIndex = brExisting.SortIndex; } br.SortIndex = largestSortIndex + 1; br.Save(); }
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); } }