public OrderBussinesObject Create(OrderBussinesObject _bussinesObject) { using (IUnitOfWork _entryPoint = dataAccess.UnitOfWork) { Order _orderEntity = _entryPoint.OrderRepository.Create(converter.Convert(_bussinesObject)); _entryPoint.Complete(); return(converter.Convert(_orderEntity)); } }
public IActionResult Post([FromBody] OrderBussinesObject _orderBussinesObject) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } OrderBussinesObject _orderObject = _bussinesLogic.OrderService.Create(_orderBussinesObject); return(Ok(_orderObject)); }
internal Order Convert(OrderBussinesObject _orderObject) { if (_orderObject == null) { return(null); } return(new Order() { Id = _orderObject.Id, OrderDate = _orderObject.OrderDate, DeliveryDate = _orderObject.DeliveryDate, CustomerId = _orderObject.CustomerId }); }
public IActionResult Put(int _id, [FromBody] OrderBussinesObject _orderBussinesFromPut) { if (_id != _orderBussinesFromPut.Id) { return(StatusCode(405, "Patch ID does not match custorem ID in json object")); } try { OrderBussinesObject _orderBussinesObject = _bussinesLogic.OrderService.Update(_orderBussinesFromPut); return(Ok(_orderBussinesObject)); } catch (InvalidOperationException exp) { return(StatusCode(404, exp.Message)); } }
public OrderBussinesObject Update(OrderBussinesObject _orderBussinesFromPUT) { using (IUnitOfWork _entryPoint = dataAccess.UnitOfWork) { Order _orderEntity = _entryPoint.OrderRepository.Get(_orderBussinesFromPUT.Id); if (_orderEntity == null) { throw new InvalidOperationException("Not found Order"); } _orderEntity.DeliveryDate = _orderBussinesFromPUT.DeliveryDate; _orderEntity.OrderDate = _orderBussinesFromPUT.OrderDate; _orderEntity.CustomerId = _orderBussinesFromPUT.CustomerId; _orderEntity.Customer = _entryPoint.CustomerRepository.Get(_orderBussinesFromPUT.CustomerId); _entryPoint.Complete(); return(converter.Convert(_orderEntity)); } }