示例#1
0
        public void UpdateBookInventoryStatus(Guid bookInventoryId, BookInventoryStatus status, string notes)
        {
            _commands.Add(new Command("UPDATE BookInventory SET Status=@status WHERE BookInventoryId = @bookInventoryId", new List <SqlParameter> {
                new SqlParameter {
                    ParameterName = "@bookInventoryId", SqlDbType = SqlDbType.UniqueIdentifier, Value = bookInventoryId
                },
                new SqlParameter {
                    ParameterName = "@status", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(status)
                }
            }));

            if (!string.IsNullOrWhiteSpace(notes))
            {
                _commands.Add(new Command("INSERT INTO History(HistoryId, BookInventoryId, Note, CreatedOn) values(@historyId, @bookInventoryId, @note, @createdOn)", new List <SqlParameter> {
                    new SqlParameter {
                        ParameterName = "@bookInventoryId", SqlDbType = SqlDbType.UniqueIdentifier, Value = bookInventoryId
                    },
                    new SqlParameter {
                        ParameterName = "@historyId", SqlDbType = SqlDbType.UniqueIdentifier, Value = Guid.NewGuid()
                    },
                    new SqlParameter {
                        ParameterName = "@createdOn", SqlDbType = SqlDbType.DateTime2, Value = DateTime.Now
                    },
                    new SqlParameter {
                        ParameterName = "@note", SqlDbType = SqlDbType.NVarChar, Value = notes
                    },
                }));
            }
        }
示例#2
0
        public void AddBookInventory(Guid bookId, Guid bookInventoryId, BookInventoryStatus status, string notes)
        {
            _commands.Add(new Command("INSERT INTO BookInventory(BookInventoryId, BookId, Status, IsRemoved) VALUES(@bookInventoryId, @bookId, @status, @isRemoved)", new List <SqlParameter> {
                new SqlParameter {
                    ParameterName = "@bookInventoryId", SqlDbType = SqlDbType.UniqueIdentifier, Value = bookInventoryId
                },
                new SqlParameter {
                    ParameterName = "@bookId", SqlDbType = SqlDbType.UniqueIdentifier, Value = bookId
                },
                new SqlParameter {
                    ParameterName = "@status", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(status)
                },
                new SqlParameter {
                    ParameterName = "@isRemoved", SqlDbType = SqlDbType.Bit, Value = false
                }
            }));

            _commands.Add(new Command("INSERT INTO History(HistoryId, BookInventoryId, Note, CreatedOn) values(@historyId, @bookInventoryId, @note, @createdOn)", new List <SqlParameter> {
                new SqlParameter {
                    ParameterName = "@bookInventoryId", SqlDbType = SqlDbType.UniqueIdentifier, Value = bookInventoryId
                },
                new SqlParameter {
                    ParameterName = "@historyId", SqlDbType = SqlDbType.UniqueIdentifier, Value = Guid.NewGuid()
                },
                new SqlParameter {
                    ParameterName = "@createdOn", SqlDbType = SqlDbType.DateTime2, Value = DateTime.Now
                },
                new SqlParameter {
                    ParameterName = "@note", SqlDbType = SqlDbType.NVarChar, Value = notes
                }
            }));
        }
示例#3
0
 public void Handle(RentedBookOutStoredEvent evt)
 {
     this.Status = BookInventoryStatus.OutStore;
 }
示例#4
0
 public void Handle(BookInventoryCreatedEvent evt)
 {
     this.BookId = evt.BookId;
     this.Id     = evt.AggregateId;
     this.Status = BookInventoryStatus.InStore;
 }
示例#5
0
 public void Handle(BookInventoryInStoredEvent evt)
 {
     this.Status = BookInventoryStatus.InStore;
 }