Пример #1
0
        internal Car Edit(string userId, Car carToUpdate)
        {
            Car foundCar = GetById(carToUpdate.Id);

            if (foundCar.UserId != userId && foundCar.Price < carToUpdate.Price)
            {
                if (_repo.BidOnCar(carToUpdate))
                {
                    foundCar.Price = carToUpdate.Price;
                    return(foundCar);
                }
                throw new Exception("Could not bid on that car.");
            }
            if (_repo.Edit(carToUpdate, userId))
            {
                return(carToUpdate);
            }
            throw new Exception("You cannot edit a car that isn't yours.");
        }
Пример #2
0
        internal Car Edit(Car carToUpdate, string userId)
        {
            Car foundCar = GetById(carToUpdate.Id);

            // NOTE Check if not the owner, and price is increasing
            if (foundCar.UserId != userId && foundCar.Price < carToUpdate.Price)
            {
                if (_repo.BidOnCar(carToUpdate))
                {
                    foundCar.Price = carToUpdate.Price;
                    return(foundCar);
                }
                throw new Exception("Could not bid on that car");
            }
            if (foundCar.UserId == userId && _repo.Edit(carToUpdate, userId))
            {
                return(carToUpdate);
            }
            throw new Exception("You cant edit that, it is not yo car!");
        }