Created
January 20, 2018 23:39
-
-
Save aramkoukia/2c0e9600650f32ed2ffd6328d9c5e31f to your computer and use it in GitHub Desktop.
Read Model Product Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.Http; | |
using MicroServices.Common.Exceptions; | |
namespace Products.ReadModels.Service.Controllers | |
{ | |
public class ProductsController : ApiController | |
{ | |
[HttpGet] | |
public IHttpActionResult Get(Guid id) | |
{ | |
var view = ServiceLocator.ProductView; | |
try | |
{ | |
var dto = view.GetById(id); | |
return Ok(dto); | |
} | |
catch (ReadModelNotFoundException) | |
{ | |
return NotFound(); | |
} | |
} | |
[HttpGet] | |
public IHttpActionResult Get() | |
{ | |
var view = ServiceLocator.ProductView; | |
var result = view.GetAll(); | |
return Ok(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment