partial void OnHandle(OrderDeleted @event) { Entities.OrderEntity entity = OrderRepository.Load(@event.Rsn); entity.IsLogicallyDeleted = true; OrderRepository.Update(entity); }
partial void OnHandle(OrderUpdated @event) { Entities.OrderEntity entity = OrderRepository.Load(@event.Rsn); entity = AutomapHelper.Automap(@event, entity); OrderRepository.Update(entity); }
public int Insert(Entities.OrderEntity order) { Random rdn = new Random(); order.OrderID = rdn.Next(1000); list.Add(order); return(order.OrderID); }
public static Domain.Models.Order Map(Entities.OrderEntity order) { return(new Domain.Models.Order { OrderNumber = order.Id, TimeStamp = (DateTime)order.OrderDate, CustomerPlaced = MapperCustomer.Map(order.Customer) }); }
/// <summary> /// Turn a map order with their orderlines into a model order with model orderlines /// </summary> /// <param name="order"></param> /// <returns></returns> public static Domain.Models.Order MapOrderWithOrderLines(Entities.OrderEntity order) { return(new Domain.Models.Order { OrderNumber = order.Id, Purchase = order.Orderlines.Select(MapperOrderLine.Map).ToList(), TimeStamp = (DateTime)order.OrderDate }); }
/// <summary> /// Turn an entity order with the location and customer and it's orderlines into objects /// </summary> /// <param name="order"></param> /// <returns></returns> public static Domain.Models.Order MapOrderWithLocationCustomerAndOrderLines(Entities.OrderEntity order) { return(new Domain.Models.Order { OrderNumber = order.Id, Purchase = order.Orderlines.Select(MapperOrderLine.Map).ToList(), TimeStamp = (DateTime)order.OrderDate, CustomerPlaced = MapperCustomer.Map(order.Customer), LocationPlaced = MapperLocation.Map(order.Location) }); }
public static Model.Order EntityToModel(this Entities.OrderEntity order) { return(new Model.Order { Discount = order.Discount, PaymentId = order.PaymentId, Shipment = order.Shipment, ShipmentId = order.ShipmentId, SubTotal = order.SubTotal, Taxes = order.Taxes, Total = order.Total, Id = order.Id, IsSync = order.IsSync }); }
/// <summary> /// Logically delete an existing instance of the <see cref="Entities.OrderEntity"/> /// </summary> public IServiceResponse DeleteOrder(IServiceRequestWithData <Cqrs.Authentication.ISingleSignOnToken, Entities.OrderEntity> serviceRequest) { AuthenticationTokenHelper.SetAuthenticationToken(serviceRequest.AuthenticationToken); CorrelationIdHelper.SetCorrelationId(serviceRequest.CorrelationId); UnitOfWorkService.SetCommitter(this); Entities.OrderEntity item = serviceRequest.Data; var locatedItem = OrderRepository.Load(item.Rsn, false); if (locatedItem == null) { return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity> { State = ServiceResponseStateType.FailedValidation })); } if (locatedItem.IsLogicallyDeleted) { return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity> { State = ServiceResponseStateType.FailedValidation })); } var command = new DeleteOrderCommand(item.Rsn); ServiceResponseStateType?serviceResponseStateType = null; OnDeleteOrder(serviceRequest, ref command, locatedItem, ref serviceResponseStateType); if (serviceResponseStateType != null && serviceResponseStateType != ServiceResponseStateType.Succeeded) { return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity> { State = serviceResponseStateType.Value })); } CommandSender.Send(command); OnDeletedOrder(serviceRequest, ref command, locatedItem, ref serviceResponseStateType); if (serviceResponseStateType != null && serviceResponseStateType != ServiceResponseStateType.Succeeded) { return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity> { State = serviceResponseStateType.Value })); } UnitOfWorkService.Commit(this); return(CompleteResponse(new ServiceResponse())); }
/// <summary> /// Create a new instance of the <see cref="Entities.OrderEntity"/> /// </summary> public IServiceResponseWithResultData <Entities.OrderEntity> CreateOrder(IServiceRequestWithData <Cqrs.Authentication.ISingleSignOnToken, Entities.OrderEntity> serviceRequest) { AuthenticationTokenHelper.SetAuthenticationToken(serviceRequest.AuthenticationToken); CorrelationIdHelper.SetCorrelationId(serviceRequest.CorrelationId); UnitOfWorkService.SetCommitter(this); Entities.OrderEntity item = serviceRequest.Data; if (item.Rsn == Guid.Empty) { item.Rsn = Guid.NewGuid(); } var command = new CreateOrderCommand(item.Rsn, item.OrderId, item.CustomerId, item.EmployeeId, item.OrderDate, item.RequiredDate, item.ShippedDate, item.ShipViaId, item.Freight, item.ShipName, item.ShipAddress, item.ShipCity, item.ShipRegion, item.ShipPostalCode, item.ShipCountry); OnCreateOrder(serviceRequest, command); CommandSender.Send(command); OnCreatedOrder(serviceRequest, command); UnitOfWorkService.Commit(this); return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity>(item))); }
/// <summary> /// Update an existing instance of the <see cref="Entities.OrderEntity"/> /// </summary> public IServiceResponseWithResultData <Entities.OrderEntity> UpdateOrder(IServiceRequestWithData <Cqrs.Authentication.ISingleSignOnToken, Entities.OrderEntity> serviceRequest) { AuthenticationTokenHelper.SetAuthenticationToken(serviceRequest.AuthenticationToken); CorrelationIdHelper.SetCorrelationId(serviceRequest.CorrelationId); UnitOfWorkService.SetCommitter(this); Entities.OrderEntity item = serviceRequest.Data; var locatedItem = OrderRepository.Load(item.Rsn); if (locatedItem == null) { return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity> { State = ServiceResponseStateType.FailedValidation })); } var command = new UpdateOrderCommand(item.Rsn, item.OrderId, item.CustomerId, item.EmployeeId, item.OrderDate, item.RequiredDate, item.ShippedDate, item.ShipViaId, item.Freight, item.ShipName, item.ShipAddress, item.ShipCity, item.ShipRegion, item.ShipPostalCode, item.ShipCountry); ServiceResponseStateType?serviceResponseStateType = null; OnUpdateOrder(serviceRequest, ref command, locatedItem, ref serviceResponseStateType); if (serviceResponseStateType != null && serviceResponseStateType != ServiceResponseStateType.Succeeded) { return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity> { State = serviceResponseStateType.Value })); } CommandSender.Send(command); OnUpdatedOrder(serviceRequest, ref command, locatedItem, ref serviceResponseStateType); if (serviceResponseStateType != null && serviceResponseStateType != ServiceResponseStateType.Succeeded) { return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity> { State = serviceResponseStateType.Value })); } UnitOfWorkService.Commit(this); return(CompleteResponse(new ServiceResponseWithResultData <Entities.OrderEntity>(item))); }
partial void OnDeletedOrder(IServiceRequestWithData <Cqrs.Authentication.ISingleSignOnToken, Entities.OrderEntity> serviceRequest, ref DeleteOrderCommand command, Entities.OrderEntity locatedItem, ref ServiceResponseStateType?serviceResponseStateType);
partial void OnHandle(OrderCreated @event) { Entities.OrderEntity entity = AutomapHelper.Automap <OrderCreated, Entities.OrderEntity>(@event); OrderRepository.Create(entity); }
public bool Update(Entities.OrderEntity order) { return(true); }