Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Created January 21, 2018 22:57
Show Gist options
  • Select an option

  • Save aramkoukia/1d450103fde02b7d121648715fed12a7 to your computer and use it in GitHub Desktop.

Select an option

Save aramkoukia/1d450103fde02b7d121648715fed12a7 to your computer and use it in GitHub Desktop.
Orders Read Model Controller
using System;
using System.Web.Http;
using MicroServices.Common.Exceptions;
namespace Sales.ReadModels.Service.Controllers
{
public class OrdersController : ApiController
{
[HttpGet]
public IHttpActionResult Get(Guid id)
{
var view = ServiceLocator.BrandView;
try
{
var dto = view.GetById(id);
return Ok(dto);
}
catch (ReadModelNotFoundException)
{
return NotFound();
}
}
[HttpGet]
public IHttpActionResult Get()
{
var view = ServiceLocator.BrandView;
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