Ejemplo n.º 1
0
        //Methods in Domain Services are
        //   - verbs known in the ubiquitous language
        //   - have simple (primitive) attributes, no domain entities
        public bool PlanDelivery(string deliveryId, string arrivalTimeForeseen, int deliveryOrder)
        {
            try
            {
                //Start a Unit Of Work
                _unitOfWork.Start();

                //Get the delivery to be planned.
                var deliveryToBePlanned = _deliveryRepository.GetById(deliveryId);

                //Set delivery as planned
                deliveryToBePlanned.SetPlanned();
                _deliveryRepository.Update(deliveryToBePlanned);

                //Create a planned delivery with foreseen arrivaltime and delivery order
                var plannedDelivery = PlannedDelivery.Create(deliveryToBePlanned.Id, arrivalTimeForeseen, deliveryOrder);
                _plannedDeliveryRepository.Add(plannedDelivery);

                //Commit the Unit Of Work
                _unitOfWork.Commit();

                return(true);
            }
            catch (Exception ex)
            {
                //Log your exception
                //Commit the Unit Of Work
                _unitOfWork.RollBack();
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static object MappingMsgInforByName(PlannedDelivery msg, string header)
        {
            if (header.IsMemberOfList(DeliveryHeader.FranFabrikLager, DeliveryHeader.TillLager))
            {
                return(msg.Warehouse);
            }
            if (header.Equals(DeliveryHeader.TelTransportor))
            {
                return(msg.CarMobileNo);
            }
            if (header.Equals(DeliveryHeader.Transportor))
            {
                return(msg.Carrier);
            }
            if (header.IsMemberOfList(DeliveryHeader.Sandning, DeliveryHeader.Sandningsnr))
            {
                return(msg.FreightNo);
            }
            if (header.Equals(DeliveryHeader.AntalOrderrader))
            {
                return(msg.NoOfRows);                                               //
            }
            if (header.Equals(DeliveryHeader.Artikel))
            {
                return(msg.ItemName);
            }
            if (header.IsMemberOfList(DeliveryHeader.Summa, DeliveryHeader.SummaKvantitet))
            {
                return(msg.QuantitySum);
            }
            if (header.Equals(DeliveryHeader.Planeradankomst))
            {
                return(msg.PlannedDeliveryDate != null ? $"{msg.PlannedDeliveryDate:yyyy-MM-dd}" : string.Empty);
            }

            if (header.Equals(DeliveryHeader.LevForsakran))
            {
                return(msg.OrderNo);
            }

            return(msg.FreightNo);
        }