Beispiel #1
0
        public Car Update(string id, ExtendedRequestMessage megaRequest)
        {
            if (megaRequest.Weight > 1000.0 || megaRequest.Weight < 0)
            {
                throw new Exception("Wrong format of weight parameter");
            }

            var car = repositoryCar.Get(id);

            if (car == null)
            {
                throw new Exception("Car was not found");
            }

            var updatedCar = repositoryCar.Update(car.Id, megaRequest);

            return(updatedCar);
        }
Beispiel #2
0
        public Car Create(ExtendedRequestMessage requestWhichCreate)
        {
            if (requestWhichCreate.Weight > 1000.0 || requestWhichCreate.Weight < 0)
            {
                throw new Exception("Wrong format of weight parameter");
            }

            var car = new Car
            {
                Id     = requestWhichCreate.Id,
                Mark   = requestWhichCreate.Mark,
                Model  = requestWhichCreate.Model,
                Name   = requestWhichCreate.Name,
                Weight = requestWhichCreate.Weight
            };

            repositoryCar.Save(car);
            return(car);
        }