public ActionResult <RealEstate> BuyHouse([FromRoute] int id, [FromBody] BuyModel buy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var house = _context.RealEstate.Find(id);

            if (house == null)
            {
                return(BadRequest());
            }
            house.BuyDate = DateTime.Now;
            _context.SaveChanges();
            return(Ok(house));
        }
示例#2
0
        public ActionResult <Asset> SellAsset([FromRoute] int id, [FromBody] SellModel sold)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var asset = _context.Asset.Find(id);

            if (asset == null)
            {
                return(BadRequest());
            }
            asset.SoldDate = DateTime.Now;
            asset.SoldTo   = sold.Name;
            _context.SaveChanges();
            return(Ok(asset));
        }