public async Task <ApplicationResult> Edit(ShipmentDetailModel model)
        {
            ShipmentDetailModelValidator validator = new ShipmentDetailModelValidator();
            ValidationResult             result    = await validator.ValidateAsync(model);

            if (result.IsValid)
            {
                Shipment shipment = _mapper.Map <Shipment>(model);
                if (shipment.Status == ShipmentStatus.Cancelled)
                {
                    shipment.IsDeleted = true;
                }
                int id = await _service.Update(shipment);

                await _eventManager.CreateEvent(EntityEventType.Shipping, id, Events.Shipment.Edited);

                if (model.Status == ShipmentStatus.Cancelled)
                {
                    await _eventManager.CreateEvent(EntityEventType.Shipping, model.Id, Events.Shipment.Cancelled);
                }
                else if (model.Status == ShipmentStatus.Shipped)
                {
                    await _eventManager.CreateEvent(EntityEventType.Shipping, model.Id, Events.Shipment.Shipped);
                }
                return(ApplicationResult.Success("Shipment edited", id));
            }
            return(ApplicationResult.Error(result));
        }
        public async Task <ApplicationResult> Create(ShipmentDetailModel model)
        {
            ShipmentDetailModelValidator validator = new ShipmentDetailModelValidator();
            ValidationResult             result    = await validator.ValidateAsync(model);

            if (result.IsValid)
            {
                Shipment shipment = _mapper.Map <Shipment>(model);
                int      id       = await _service.Create(shipment);

                await _eventManager.CreateEvent(EntityEventType.Shipping, id, Events.Shipment.Created);

                return(ApplicationResult.Success("Shipment created", id));
            }
            return(ApplicationResult.Error(result));
        }