public HttpResponseMessage Post([FromBody] SaveFacilityParameter value) { ModelState.EnsureValidModelStateWithHttpResponseException(); var param = _userIdentityProvider.SetUserIdentity(value.Map().To <CreateFacilityParameters>()); var result = _facilityService.CreateFacility(param); return(result.ToHttpResponseMessage(HttpVerbs.Post)); }
public HttpResponseMessage SetStatus(string lotKey, SetLotStatusDto values) { var input = new SetLotStatusParameter { LotKey = lotKey, QualityStatus = values.Status, }; var result = _lotService.SetLotQualityStatus(_userIdentityProvider.SetUserIdentity(input)); return(result.ToMapped().Response <LotStatInfoResponse>(HttpVerbs.Put)); }
// POST api/millandwetdown public void Post([FromBody] CreateMillAndWetdownRequest value) { if (!ModelState.IsValid || value == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var dto = value.Map().To <CreateMillAndWetdownParameters>(); var result = _millAndWetDownService.CreateMillAndWetdown(_userIdentityProvider.SetUserIdentity(dto)); result.EnsureSuccessWithHttpResponseException(HttpVerbs.Post); }
public HttpResponseMessage Put(string id, [FromBody] UpdateLocationParameter values) { ModelState.EnsureValidModelStateWithHttpResponseException(); var input = values.Map().To <UpdateLocationParameters>(); input.LocationKey = id; _userIdentityProvider.SetUserIdentity(input); var result = _facilityService.UpdateLocation(input); return(result.ToHttpResponseMessage(HttpVerbs.Put)); }
public HttpResponseMessage Post([FromBody] CreateSampleOrderRequest values) { ModelState.EnsureValidModelStateWithHttpResponseException(); var parameters = _userIdentityProvider.SetUserIdentity(values.Map().To <SetSampleOrderParameters>()); var result = _sampleOrderService.SetSampleOrder(parameters); result.EnsureSuccessWithHttpResponseException(HttpVerbs.Post); return(new HttpResponseMessage(HttpStatusCode.Created) { Content = Get(result.ResultingObject).ToJSONContent() }); }
// POST api/notebooks/5/notes public HttpResponseMessage Post(string notebookKey, [FromBody] NoteDto value) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } _identityProvider.SetUserIdentity(value); var result = _notebookService.AddNote(notebookKey, value); var message = result.ToHttpResponseMessage(HttpVerbs.Post); message.Content = new ObjectContent <INoteReturn>(result.ResultingObject, new JsonMediaTypeFormatter()); return(message); }
public HttpResponseMessage Post(CreatePackSchedule values) { if (values == null || !ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = ModelState.GetErrorSummary() }); } var parameters = values.Map().To <CreatePackScheduleParameters>(); _userIdentityProvider.SetUserIdentity(parameters); return(_productionService.CreatePackSchedule(parameters).ToHttpResponseMessage(HttpVerbs.Post)); }
public HttpResponseMessage Put(string contractKey, [FromBody] UpdateCustomerContractRequest values) { if (!ModelState.IsValid) { var message = new HttpResponseMessage(HttpStatusCode.BadRequest); message.Content = new StringContent("The values contain some invalid data. Please check the data and try again."); throw new HttpResponseException(message); } var dto = values.Map().To <Services.Models.Parameters.UpdateCustomerContractParameters>(); dto.ContractKey = contractKey; _identityProvider.SetUserIdentity(dto); return(_salesService.UpdateCustomerContract(dto).ToHttpResponseMessage(System.Web.Mvc.HttpVerbs.Put)); }
public string Post([FromBody] CreateTreatmentOrderRequestParameter data) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var param = data.Map().To <CreateTreatmentOrderParameters>(); _userIdentityProvider.SetUserIdentity(param); var result = _treatmentOrderService.CreateInventoryTreatmentOrder(param); result.EnsureSuccessWithHttpResponseException(HttpVerbs.Post); return(result.ResultingObject); }
// POST api/productionresults public HttpResponseMessage Post([FromBody] CreateProductionBatchResultsDto value) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("The supplied values are not valid. Please review data for errors and retry.") }); } var parameters = _userIdentityProvider.SetUserIdentity(value.Map().To <CreateProductionBatchResultsParameters>()); var saveResult = _productionResultsService.CreateProductionBatchResults(parameters); return(saveResult.ToHttpResponseMessage(HttpVerbs.Post)); }
public HttpResponseMessage Post([FromBody] CreateIntraWarehouseOrder data) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var param = data.Map().To <CreateIntraWarehouseOrderParameters>(); _userIdentityProvider.SetUserIdentity(param); var results = _intraWarehouseOrderService.CreateIntraWarehouseOrder(param); results.EnsureSuccessWithHttpResponseException(HttpVerbs.Post); return(results.ToHttpResponseMessage(HttpVerbs.Post)); }
public async Task <HttpResponseMessage> Post([FromBody] InventoryAdjustmentDto value) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } _userIdentityProvider.SetUserIdentity(value); var result = _inventoryAdjustmentsService.CreateInventoryAdjustment(value); var httpResponse = result.ToHttpResponseMessage(HttpVerbs.Post); if (!result.Success) { return(httpResponse); } try { var getAdjustmentResult = await Get(result.ResultingObject); httpResponse.Content = new ObjectContent <InventoryAdjustment>(getAdjustmentResult, new JsonMediaTypeFormatter()); } catch { } return(httpResponse); }
public HttpResponseMessage Post(ReceiveInventoryDto values) { var parameters = values.Map().To <Services.Models.Parameters.ReceiveInventoryParameters>(); _userIdentityProvider.SetUserIdentity(parameters); var result = _inventoryService.ReceiveInventory(parameters); return(result.ToHttpResponseMessage(HttpVerbs.Post)); }
public HttpResponseMessage Post([FromBody] CreateSalesOrderRequest values) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent(ModelState.GetErrorSummary()) }); } var param = values.Map().To <CreateSalesOrderParameters>(); _userIdentityProvider.SetUserIdentity(param); var result = _salesService.CreateSalesOrder(param); return(result.ToHttpResponseMessage(HttpVerbs.Post)); }
public HttpResponseMessage Post([FromBody] CreateChileMaterialsReceivedRequest values) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("The supplied values are not valid. Please review data for errors and retry.") }); } var parameters = _userIdentityProvider.SetUserIdentity(values.Map().To <CreateChileMaterialsReceivedParameters>()); var result = _materialsReceivedService.CreateChileMaterialsReceived(parameters); result.EnsureSuccessWithHttpResponseException(HttpVerbs.Post); return(new HttpResponseMessage(HttpStatusCode.Created) { Content = Get(result.ResultingObject).ToJSONContent() }); }
// POST api/{pickedInventoryContext}/{contextKey}/pickedInventory // POST api/movements/2013-01-01/pickedInventory public async Task Post(InventoryOrderEnum pickedInventoryContext, string contextKey, [FromBody] PickedInventoryDto value) { var service = InventoryPickingServiceFactory.ResolveComponent(pickedInventoryContext); var setPickedInventory = value.Map().To <SetPickedInventoryParameters>(); _identityProvider.SetUserIdentity(setPickedInventory); var result = await Task.Run(() => service.SetPickedInventory(contextKey, setPickedInventory)); result.EnsureSuccessWithHttpResponseException(HttpVerbs.Put); }
public HttpResponseMessage Post([FromBody] CreateProductionBatchDto value) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var dto = value.Map().To <CreateProductionBatchParameters>(); _userIdentityProvider.SetUserIdentity(dto); var createBatchResult = _productionService.CreateProductionBatch(dto); if (!createBatchResult.Success) { return(createBatchResult.ToHttpResponseMessage(HttpVerbs.Post)); } return(new HttpResponseMessage(HttpStatusCode.Created) { Content = new ObjectContent <ICreateProductionBatchReturn>(createBatchResult.ResultingObject, new JsonMediaTypeFormatter()) }); }
public async Task Post(InventoryOrderEnum pickingContext, string contextKey, [FromBody] IEnumerable <PickedInventoryItemDto> value) { var service = InventoryPickingServiceFactory.ResolveComponent(pickingContext); var pickedItemParameters = new SetPickedInventoryParameters { PickedInventoryItems = value.Project().To <SetPickedInventoryItemParameters>() }; _identityProvider.SetUserIdentity(pickedItemParameters); var result = await Task.Run(() => service.SetPickedInventory(contextKey, pickedItemParameters)); result.EnsureSuccessWithHttpResponseException(HttpVerbs.Put); }
// GET: api/products/ public async Task <HttpResponseMessage> Post([FromBody] CreateProductDto values) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } _userIdentityProvider.SetUserIdentity(values); Task <IResult <string> > task; switch (values.ProductType) { case ProductTypeEnum.Additive: task = Task.Run(() => _productsService.CreateAdditiveProduct(values)); break; case ProductTypeEnum.Chile: task = Task.Run(() => _productsService.CreateChileProduct(values)); break; case ProductTypeEnum.Packaging: task = Task.Run(() => _productsService.CreatePackagingProduct(values)); break; case ProductTypeEnum.NonInventory: task = Task.Run(() => _productsService.CreateNonInventoryProduct(values)); break; default: throw new NotSupportedException(string.Format("The ProductTypeEnum '{0}' is not supported.", values.ProductType)); } await Task.WhenAll(new Task[] { task }); return(task.Result.ToHttpResponseMessage(HttpVerbs.Post)); }
// POST api/contacts public HttpResponseMessage Post([FromBody] CreateContactRequest value) { if (!ModelState.IsValid) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("The values contain some invalid data. Please check the data and try again.") }); } var parameters = _identityProvider.SetUserIdentity(value.Map().To <CreateContactParameters>()); var results = _companyService.CreateContact(parameters); results.EnsureSuccessWithHttpResponseException(HttpVerbs.Post); var getContactResult = _companyService.GetContact(results.ResultingObject); getContactResult.EnsureSuccessWithHttpResponseException(); return(new HttpResponseMessage(HttpStatusCode.Created) { Content = getContactResult.ResultingObject.ToJSONContent() }); }
public void PostAndClose(string id, [FromBody] PostAndCloseShipmentOrderRequestParameter data) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var param = data.Map().To <PostParameters>(); _userIdentityProvider.SetUserIdentity(param); param.OrderKey = id; var result = _inventoryShipmentOrderService.Post(param); result.EnsureSuccessWithHttpResponseException(HttpVerbs.Put); }
// POST: api/products/123/specs public HttpResponseMessage Post(string productKey, [FromBody] SetChileProductAttributeRangesRequest values) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = ModelState.GetErrorSummary() }); } var parameters = _userIdentityProvider.SetUserIdentity(values.Map().To <SetChileProductAttributeRangesParameters>()); parameters.ChileProductKey = productKey; var result = _productService.SetChileProductAttributeRanges(parameters); return(result.ToHttpResponseMessage(HttpVerbs.Post)); }
public HttpResponseMessage Post(string customerKey, string productKey, [FromBody] IEnumerable <CustomerProductRangeRequest> values) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = ModelState.GetErrorSummary() }); } var parameters = _userIdentityProvider.SetUserIdentity(new SetCustomerProductRangesRequest { CustomerKey = customerKey, ChileProductKey = productKey, AttributeRanges = values }.Map().To <SetCustomerProductAttributeRangesParameters>()); var result = _salesService.SetCustomerChileProductAttributeRanges(parameters); return(result.ToHttpResponseMessage(HttpVerbs.Post)); }