Exemple #1
0
 public void SetUp()
 {
     _context = Substitute.For <IOrangeBricksContext>();
     _context.Properties.Returns(Substitute.For <IDbSet <Domain.Models.Property> >());
     _handler      = new CreatePropertyCommandHandler(_context);
     _offerHandler = new MakeOfferCommandHandler(_context);
 }
 public void SetUp()
 {
     _context    = Substitute.For <IOrangeBricksContext>();
     _properties = Substitute.For <IDbSet <Models.Property> >();
     _context.Properties.Returns(_properties);
     _handler = new MakeOfferCommandHandler(_context);
 }
Exemple #3
0
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            var handler = new MakeOfferCommandHandler(_context);

            handler.Handle(command);

            return(RedirectToAction("Index"));
        }
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            var handler = new MakeOfferCommandHandler(this._context);

            command.BuyerUserId = this.User.Identity.GetUserId();
            handler.Handle(command);

            return(this.RedirectToAction("Index"));
        }
Exemple #5
0
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            var handler = new MakeOfferCommandHandler(_context);

            string buyerId = User.Identity.GetUserId();

            handler.Handle(command, buyerId);

            return(RedirectToAction("Index"));
        }
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            command.BuyerUserId = UserId;

            var handler = new MakeOfferCommandHandler(Context);

            handler.Handle(command);

            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            //todo: come up with more elegant way of handling this
            command.BuyerUserId = User.Identity.GetUserId();
            var handler = new MakeOfferCommandHandler(_context);

            handler.Handle(command);

            return(RedirectToAction("Index"));
        }
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            var handler = new MakeOfferCommandHandler(_context);

            // Add the user id of the buyer making the offer.
            command.UserId = User.Identity.GetUserId();

            handler.Handle(command);

            return(RedirectToAction("Index"));
        }
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            // Set the BuyerUserId before calling the command handler
            command.BuyerUserId = User.Identity.GetUserId();

            var handler = new MakeOfferCommandHandler(_context);

            handler.Handle(command);

            return(RedirectToAction("Index"));
        }
Exemple #10
0
        public ActionResult MakeOffer(MakeOfferCommand command)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var handler = new MakeOfferCommandHandler(_context);

                    command.BuyerUserId = User.Identity.GetUserId();

                    if (!handler.Handle(command))
                    {
                        ModelState.AddModelError("", "You already placed an offer.");
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Adding offer failed.");
            }
            var property = _context.Properties.Find(command.PropertyId);

            MakeOfferViewModel model = new MakeOfferViewModel
            {
                PropertyId   = property.Id,
                PropertyType = property.PropertyType,
                StreetName   = property.StreetName,
                Offer        = property.SuggestedAskingPrice
            };

            PropertiesViewModel m = new PropertiesViewModel
            {
                Search     = "",
                Properties = new System.Collections.Generic.List <PropertyViewModel>
                {
                    new PropertyViewModel
                    {
                        Id                   = property.Id,
                        PropertyType         = property.PropertyType,
                        StreetName           = property.StreetName,
                        Description          = property.Description,
                        NumberOfBedrooms     = property.NumberOfBedrooms,
                        IsListedForSale      = property.IsListedForSale,
                        SuggestedAskingPrice = property.SuggestedAskingPrice
                    }
                }
            };

            return(View("Index", m));
        }
        public void SetUp()
        {
            // Setup context mocks
            _context = Substitute.For <IOrangeBricksContext>();

            // Setup propery mocks
            var properties = new List <Models.Property> {
                new Models.Property {
                    Id = 1, Description = "Small house", StreetName = "1 Somewhere", NumberOfBedrooms = 1, IsListedForSale = true, PropertyType = "House"
                }
            };

            var mockPropertySet = Substitute.For <IDbSet <Models.Property> >()
                                  .Initialize(properties.AsQueryable());

            _context.Properties.Returns(mockPropertySet);

            _handler = new MakeOfferCommandHandler(_context);
        }
Exemple #12
0
        public void SetUp()
        {
            _context = Substitute.For <IOrangeBricksContext>();
            _handler = new MakeOfferCommandHandler(_context);

            var properties = new List <Models.Property> {
                new Models.Property {
                    Id = 1, StreetName = "Smith Street", Description = "", IsListedForSale = true
                },
                new Models.Property {
                    Id = 2, StreetName = "Jones Street", Description = "", IsListedForSale = true
                }
            };

            var mockSet = Substitute.For <IDbSet <Models.Property>, IQueryable <Models.Property> >()
                          .Initialize(properties.AsQueryable(), p => p.Id);

            _context.Properties.Returns(mockSet);
            _context.Offers.Returns(Substitute.For <IDbSet <Offer> >());
        }