示例#1
0
        public bool TriggerReceive(int donationPlanId)
        {
            try
            {
                var donationDetail =
                    _donationPlanDetailService.FindBy(r => r.DonationHeaderPlanID == donationPlanId).ToList();

                foreach (var detail in donationDetail)
                {
                    var receiptAllocation = new Cats.Models.Hubs.ReceiptAllocation
                    {
                        ReceiptAllocationID = Guid.NewGuid(),
                        CommodityID         =
                            detail.DonationPlanHeader.CommodityID,
                        IsCommited = false,
                        ETA        =
                            detail.DonationPlanHeader.ETA,
                        ProjectNumber = "PC",
                        SINumber      =
                            detail.DonationPlanHeader.ShippingInstruction.Value,

                        QuantityInMT = detail.AllocatedAmount,
                        HubID        = detail.HubID,
                        ProgramID    =
                            detail.DonationPlanHeader.ProgramID,

                        GiftCertificateDetailID = detail.DonationPlanHeader.GiftCertificateID,
                        CommoditySourceID       = 1,
                        IsClosed    = false,
                        PartitionId = 0
                    };

                    _receiptAllocationService.AddReceiptAllocation(receiptAllocation);
                }
                return(true);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException e)
            {
                var outputLines = new List <string>();
                foreach (var eve in e.EntityValidationErrors)
                {
                    outputLines.Add(string.Format(
                                        "{0}: Entity of type \"{1}\" in state \"{2}\" has the following validation errors:",
                                        DateTime.Now, eve.Entry.Entity.GetType().Name, eve.Entry.State));
                    outputLines.AddRange(eve.ValidationErrors.Select(ve => string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)));
                }
                // System.IO.File.AppendAllLines(@"c:\temp\errors.txt", outputLines);
                throw;
            }
        }
示例#2
0
        public bool TriggerReceive(int donationPlanId)
        {
            try
            {
                var donationDetail =
                    _donationPlanDetailService.FindBy(r => r.DonationHeaderPlanID == donationPlanId).ToList();

                foreach (var detail in donationDetail)
                {
                    var receiptAllocation = new Cats.Models.Hubs.ReceiptAllocation
                                                {
                                                    ReceiptAllocationID = Guid.NewGuid(),
                                                    CommodityID =
                                                        detail.DonationPlanHeader.CommodityID,
                                                    IsCommited = false,
                                                    ETA =
                                                        detail.DonationPlanHeader.ETA,
                                                    ProjectNumber = "PC",
                                                    SINumber =
                                                        detail.DonationPlanHeader.ShippingInstruction.Value,

                                                    QuantityInMT = detail.AllocatedAmount,
                                                    HubID = detail.HubID,
                                                    ProgramID =
                                                        detail.DonationPlanHeader.ProgramID,

                                                    GiftCertificateDetailID = detail.DonationPlanHeader.GiftCertificateID,
                                                    CommoditySourceID = 1,
                                                    IsClosed = false,
                                                    PartitionId = 0
                                                };

                    _receiptAllocationService.AddReceiptAllocation(receiptAllocation);
                }
                return true;
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException e)
            {
                var outputLines = new List<string>();
                foreach (var eve in e.EntityValidationErrors)
                {
                    outputLines.Add(string.Format(
                        "{0}: Entity of type \"{1}\" in state \"{2}\" has the following validation errors:",
                        DateTime.Now, eve.Entry.Entity.GetType().Name, eve.Entry.State));
                    outputLines.AddRange(eve.ValidationErrors.Select(ve => string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)));
                }
                // System.IO.File.AppendAllLines(@"c:\temp\errors.txt", outputLines);
                throw;
            }
        }