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));
        }
    }
示例#3
0
    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);
        }
    }
示例#4
0
    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);
        }
    }
示例#5
0
    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);
    }
示例#8
0
    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));
        }
    }
示例#10
0
    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));
    }