Esempio n. 1
0
        /// <summary>
        /// Add / Update Vehicle Make
        /// </summary>
        public VehicleMake AddUpdateVehicleMake(VehicleMake vehicleMake)
        {
            VehicleMake dbVersion = vehicleMakeRepository.Find(vehicleMake.VehicleMakeId);

            if (vehicleMakeRepository.VehicleMakeCodeDuplicationCheck(vehicleMake))
            {
                throw new CaresException(Resources.FleetPool.VehicleMake.VehicleMakeCodeDuplicationError);
            }

            if (dbVersion != null)
            {
                UpdateVehicleMakeProperties(vehicleMake, dbVersion);
                vehicleMakeRepository.Update(dbVersion);
            }
            else
            {
                dbVersion = new VehicleMake();
                SetVehicleMakeProperties(vehicleMake, dbVersion);
                vehicleMakeRepository.Add(dbVersion);
            }
            vehicleMakeRepository.SaveChanges();
            // To Load the proprties
            return(vehicleMakeRepository.Find(dbVersion.VehicleMakeId));
        }