public void Execute(CreateActivityNoteCommand command)
        {
            _log.InfoFormat("Execute CreateActivityCommandHandler - Command Id {0} ", command.CommandId);
            _log.InfoFormat("Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
            try
            {
                if (_context.tblActivityDocument.Any(s=>s.Id==command.DocumentId))
                    return;
                tblActivityDocument doc = new tblActivityDocument();
                doc.Id = command.DocumentId;
                doc.ActivityDate = command.ActivityDate;
                doc.ActivityReference = command.DocumentReference;
                doc.ActivityTypeId = command.ActivityTypeId;
                doc.CentreId = command.CentreId;
                doc.RouteId = command.RouteId;
                doc.ClerkId = command.DocumentIssuerCostCentreId;
                doc.CommoditySupplierId = command.CommoditySupplierId;
                doc.Description = command.Description;
                doc.IM_DateCreated = DateTime.Now;
                doc.IM_DateLastUpdated = DateTime.Now;
                doc.IM_Status =0;
                doc.SeasonId = command.SeasonId;
                doc.hubId = command.HubId;
                doc.ActivityReference = command.DocumentReference;
                doc.CommodityProducerId = command.CommodityProducerId;
                
                
                _context.tblActivityDocument.AddObject(doc);
                _context.SaveChanges();

            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString());
                _log.Error("CreateCommodityPurchaseCommandHandler exception ", ex);
                throw;
            }
            
        }
Ejemplo n.º 2
0
 private void AddCreateCommandToExecute()
 {
     var cmd =new CreateActivityNoteCommand();
     cmd.ActivityDate = ActivityDate;
     cmd.ActivityTypeId = ActivityType.Id;
     cmd.CentreId = Centre.Id;
     cmd.CommandCreatedDateTime = DateTime.Now;
     cmd.CommandGeneratedByCostCentreApplicationId = DocumentIssuerCostCentreApplicationId;
     cmd.CommandGeneratedByCostCentreId = FieldClerk.Id;
     cmd.CommandId = Guid.NewGuid();
     cmd.CommodityProducerId = Producer.Id;
     cmd.CommoditySupplierId = Supplier.Id;
     cmd.Description = Description;
     cmd.DocumentDateIssued = DateTime.Now;
     cmd.DocumentId = Id;
     cmd.DocumentIssuerCostCentreId = FieldClerk.Id;
     cmd.DocumentReference = DocumentReference;
     cmd.HubId = Hub.Id;
     cmd.RouteId = Route.Id;
     cmd.SeasonId = Season.Id;
     cmd.VersionNumber = "H-" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
     _AddCommand(cmd);
 }