public void Execute(AddActivityInputLineItemCommand command) { _log.InfoFormat("Execute AddActivityInputLineItemCommandHandler - 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)) { _log.InfoFormat("Cannot add line item. Document does not exist Execute {1} - Command Id {0} ", command.CommandId, command.GetType()); return; } if (_context.tblActivityInputLineItem.Any(s => s.Id == command.LineItemId)) { _log.InfoFormat("Cannot add line item {0}. Line item already exists", command.CommandId); return; } tblActivityInputLineItem doc = new tblActivityInputLineItem(); doc.Id = command.LineItemId; doc.ActivityId = command.DocumentId; doc.ProductId = command.ProductId; doc.Quantity = command.Quantity; doc.MF_Date = command.ManufacturedDate; doc.EP_Date = command.ExpiryDate; doc.Description = command.Description; doc.Description = command.Description; doc.IM_DateCreated = DateTime.Now; doc.IM_DateLastUpdated = DateTime.Now; doc.IM_Status = 1; _context.tblActivityInputLineItem.AddObject(doc); _context.SaveChanges(); } catch (Exception ex) { _log.ErrorFormat("Error Execute {1} - Command Id {0} ", command.CommandId, command.GetType().ToString()); _log.Error("AddActivityInputLineItemCommandHandler exception ", ex); throw; } }
/// <summary> /// Create a new tblActivityInputLineItem object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="productId">Initial value of the ProductId property.</param> /// <param name="quantity">Initial value of the Quantity property.</param> /// <param name="activityId">Initial value of the ActivityId property.</param> /// <param name="iM_DateCreated">Initial value of the IM_DateCreated property.</param> /// <param name="iM_DateLastUpdated">Initial value of the IM_DateLastUpdated property.</param> /// <param name="iM_Status">Initial value of the IM_Status property.</param> public static tblActivityInputLineItem CreatetblActivityInputLineItem(global::System.Guid id, global::System.Guid productId, global::System.Decimal quantity, global::System.Guid activityId, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status) { tblActivityInputLineItem tblActivityInputLineItem = new tblActivityInputLineItem(); tblActivityInputLineItem.Id = id; tblActivityInputLineItem.ProductId = productId; tblActivityInputLineItem.Quantity = quantity; tblActivityInputLineItem.ActivityId = activityId; tblActivityInputLineItem.IM_DateCreated = iM_DateCreated; tblActivityInputLineItem.IM_DateLastUpdated = iM_DateLastUpdated; tblActivityInputLineItem.IM_Status = iM_Status; return tblActivityInputLineItem; }
/// <summary> /// Deprecated Method for adding a new object to the tblActivityInputLineItem EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotblActivityInputLineItem(tblActivityInputLineItem tblActivityInputLineItem) { base.AddObject("tblActivityInputLineItem", tblActivityInputLineItem); }