// GET api/Product/5 public string Get(int id) { var product = productQuery.Get(id); if (product == null) { return("no product with that Id"); } return(product.ToView()); }
public IEnumerable <Exception> ValidateRequest(CreateClaimRequest request) { if (productQuery.Get(request.ProductId) == null) { return new List <Exception>() { new InvalidOperationException(string.Format("Product {0} does not exist", request.ProductId)) } } ; return(new List <Exception>()); } }
public ListResult <ProductDto> Get(int offset, int limit) { var result = _productQuery.Get(offset, limit); return(result); }
public void Post([FromBody] RegisterOrderModel model) { Guard.AgainstNull(model, "model"); Guard.AgainstNull(model.TargetSystem, "model.TargetSystem"); Guard.Against <Exception>(model.ProductIds.Count == 0, "No products have been selected."); var message = new RegisterOrderProcessCommand { CustomerName = model.CustomerName, CustomerEMail = model.CustomerEMail, TargetSystem = model.TargetSystem }; switch (model.TargetSystem.ToLower(CultureInfo.InvariantCulture)) { case "custom": { message.TargetSystemUri = "msmq://./process-custom-server"; break; } case "custom / event-source": { message.TargetSystemUri = "msmq://./process-custom-es-server"; break; } case "event-source / module": { message.TargetSystemUri = "msmq://./process-es-module-server"; break; } default: { throw new ApplicationException(string.Format("Unknown target system '{0}'.", model.TargetSystem)); } } foreach (var productIdValue in model.ProductIds) { Guid productId; if (!Guid.TryParse(productIdValue, out productId)) { throw new ArgumentException(string.Format("Product id '{0}' is not a valid guid.", productIdValue)); } var productRow = _productQuery.Get(productId); message.QuotedProducts.Add(new QuotedProduct { ProductId = productId, Description = ProductColumns.Description.MapFrom(productRow), Price = ProductColumns.Price.MapFrom(productRow) }); } _bus.Send(message, c => { c.WithRecipient(message.TargetSystemUri); c.Headers.Add(new TransportHeader { Key = "TargetSystem", Value = message.TargetSystem }); }); }
public ActionResult <ProductDto> GetProductById([FromRoute] ProductId productId) => _productQuery.Get(productId);
/// <summary> /// Gets all products /// </summary> /// <returns></returns> public List <BLModel.Product> GetAll() { return(productHelper.Get().ToList <DLModel.Product>() .ToBusinessModel <List <DLModel.Product>, List <BLModel.Product> >()); }