Esempio n. 1
0
 public void Handle(BookViewingCommand tcmdType)
 {
     using (_uow)
     {
         // This need automapping
         _uow.ViewingRepository.Add(new Models.Viewing()
         {
             BuyerId          = tcmdType.BuyerId,
             PropertyID       = tcmdType.PropertyId,
             ViewingtDateTime = tcmdType.ViewingDateTime,
             ViewStatusId     = 2, //default
             CreatedAt        = DateTime.Now,
             UpdatedAt        = DateTime.Now,
         });
         _uow.Commit();
     }
 }
        public bool Handle(BookViewingCommand command)
        {
            if (_context.Viewing.Any(x => x.BuyerId.Equals(command.BuyerId) &&
                                     x.PropertyId.Equals(command.PropertyId) &&
                                     DbFunctions.TruncateTime(x.ViewAt) ==
                                     DbFunctions.TruncateTime(command.ViewingDate)))
            {
                return(false);
            }

            var vewing = new Models.Viewing
            {
                ViewAt     = command.ViewingDate + command.ViewingTime,
                BuyerId    = command.BuyerId,
                PropertyId = command.PropertyId
            };

            _context.Viewing.Add(vewing);

            _context.SaveChanges();

            return(true);
        }