Skip to content

Commit

Permalink
updated the libraries, fixed a few issues with the domain layer, appl…
Browse files Browse the repository at this point in the history
…ied those to API layer. Looks good.
  • Loading branch information
tugberkugurlu committed Feb 11, 2013
1 parent e20acc3 commit 80010c4
Show file tree
Hide file tree
Showing 23 changed files with 130 additions and 664 deletions.
1 change: 1 addition & 0 deletions src/MvcBloggy.API.Model/MvcBloggy.API.Model.csproj
Expand Up @@ -45,6 +45,7 @@
<Compile Include="Dtos\IPaginatedDto.cs" />
<Compile Include="Dtos\PaginatedDto.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RequestCommands\ArchiveYearMonthRequestCommand.cs" />
<Compile Include="RequestCommands\IRequestCommand.cs" />
<Compile Include="RequestCommands\PaginatedRequestCommand.cs" />
<Compile Include="RequestCommands\RequestCommand.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/MvcBloggy.API/Config/RouteConfig.cs
@@ -1,4 +1,4 @@
using MvcBloggy.API.Infrastructure.Routes;
using MvcBloggy.API.Routing;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
17 changes: 7 additions & 10 deletions src/MvcBloggy.API/Config/WebAPIConfig.cs
@@ -1,17 +1,14 @@
using MvcBloggy.API.Filters;
using System;
using System.Collections.Generic;
using MvcBloggy.API.Model.RequestCommands;
using System.Linq;
using System.Net.Http.Formatting;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.ModelBinding;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
using System.Web.Http.Validation;
using System.Web.Http.Validation.Providers;
using MvcBloggy.API.Infrastructure.Controllers;
using WebAPIDoodle.Http;
using MvcBloggy.API.Model.RequestCommands;
using WebApiDoodle.Web.Controllers;
using WebApiDoodle.Web.ModelBinding;

namespace MvcBloggy.API.Config {

Expand All @@ -22,7 +19,6 @@ public static class WebAPIConfig {
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly;

//Message Handlers
config.MessageHandlers.Add(new RemoveServerHeaderMessageHandler());

//Formatters
var jqueryFormatter = config.Formatters.FirstOrDefault(x => x.GetType() == typeof(JQueryMvcFormUrlEncodedFormatter));
Expand All @@ -34,7 +30,8 @@ public static class WebAPIConfig {
config.Filters.Add(new InvalidModelStateFilterAttribute());

//Default Services
config.Services.RemoveAll(typeof(System.Web.Http.Validation.ModelValidatorProvider), v => v is InvalidModelValidatorProvider);
config.Services.RemoveAll(typeof(ModelValidatorProvider), v => v is InvalidModelValidatorProvider);
config.Services.Replace(typeof(IHttpActionSelector), new ComplexTypeAwareActionSelector());

// From DefaultContentNegotiator class:
// If ExcludeMatchOnTypeOnly is true then we don't match on type only which means
Expand Down
13 changes: 5 additions & 8 deletions src/MvcBloggy.API/Controllers/BlogPostArchivesController.cs
@@ -1,22 +1,19 @@
using MvcBloggy.API.Infrastructure.Controllers;
using GenericRepository.EntityFramework;
using MvcBloggy.API.Model.Dtos;
using MvcBloggy.API.Model.RequestCommands;
using MvcBloggy.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace MvcBloggy.API.Controllers {

public class BlogPostArchivesController : ApiController {

private readonly IEntityRepository<BlogPost> _blogPostRepository;
private readonly IEntityRepository<BlogPost, Guid> _blogPostRepository;

public BlogPostArchivesController(
IEntityRepository<BlogPost> blogPostRepository) {
IEntityRepository<BlogPost, Guid> blogPostRepository) {

_blogPostRepository = blogPostRepository;
}
Expand All @@ -26,8 +23,8 @@ public class BlogPostArchivesController : ApiController {
return _blogPostRepository.GetMonthArchives();
}

[UriParameter("lang", "page", "take", "month", "year")]
public PaginatedDto<BlogPostDto> GetBlogPostsByYearMonth(ArchiveYearMonthRequestCommand requestCmd) {
public PaginatedDto<BlogPostDto> GetBlogPostsByYearMonth(
ArchiveYearMonthRequestCommand requestCmd) {

return null;
}
Expand Down
30 changes: 5 additions & 25 deletions src/MvcBloggy.API/Controllers/BlogPostTagsController.cs
@@ -1,46 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MvcBloggy.API.Model.RequestCommands;
using MvcBloggy.Domain.Services;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.ModelBinding;
using MvcBloggy.API.Infrastructure.Controllers;
using System.ComponentModel.DataAnnotations;
using MvcBloggy.Domain.Entities;
using MvcBloggy.Domain.Services;
using GenericRepository.EntityFramework;

namespace MvcBloggy.API.Controllers {

public class BlogPostTagsController : ApiController {

private readonly IEntityRepository<BlogPost, Guid> _blogPostRepository;
private readonly IEntityRepository<Tag, Guid> _tagRepository;
private readonly IEntityRepository<TagsForBlogPost, Guid> _tagForBlogPostRepository;
private readonly IBlogService _blogService;

public BlogPostTagsController(
IEntityRepository<BlogPost, Guid> blogPostRepository,
IEntityRepository<Tag, Guid> tagRepository,
IEntityRepository<TagsForBlogPost, Guid> tagForBlogPostRepository,
IBlogService blogService) {

_blogPostRepository = blogPostRepository;
_tagRepository = tagRepository;
_tagForBlogPostRepository = tagForBlogPostRepository;
_blogService = blogService;
}

//GET /api/blogposts/tags/asp-net/asp-net-web-api
public HttpResponseMessage Get(string[] tags) {
public HttpResponseMessage GetBlogPosts(PaginatedRequestCommand requestCmd, string[] tags) {

var blogPosts = _blogPostRepository.GetAll()
.Where(x => tags.All(t => x.TagsForBlogPosts.Any(y => y.Tag.TagName == t)));
var blogPosts = _blogService.GetBlogPosts(
requestCmd.Lang, requestCmd.Page, requestCmd.Take, tags);

return new HttpResponseMessage(HttpStatusCode.OK);
}
Expand Down
12 changes: 5 additions & 7 deletions src/MvcBloggy.API/Controllers/DynamicPageArchivesController.cs
@@ -1,19 +1,17 @@
using MvcBloggy.Domain.Entities;
using GenericRepository.EntityFramework;
using MvcBloggy.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace MvcBloggy.API.Controllers {

public class DynamicPageArchivesController : ApiController {

private readonly IEntityRepository<DynamicPage> _dynamicPageRepository;
private readonly IEntityRepository<DynamicPage, Guid> _dynamicPageRepository;

public DynamicPageArchivesController(
IEntityRepository<DynamicPage> dynamicPageRepository) {
IEntityRepository<DynamicPage, Guid> dynamicPageRepository) {

_dynamicPageRepository = dynamicPageRepository;
}
Expand All @@ -23,4 +21,4 @@ public class DynamicPageArchivesController : ApiController {
return _dynamicPageRepository.GetMonthArchives();
}
}
}
}

This file was deleted.

This file was deleted.

0 comments on commit 80010c4

Please sign in to comment.