コード例 #1
0
        public AutoDto GetCar(int id)
        {
            WriteActualMethod();
            AutoManager manager = new AutoManager();

            return(DtoConverter.ConvertToDto(manager.GetAuto(id)));
        }
コード例 #2
0
        public List <AutoDto> GetAllCars()
        {
            WriteActualMethod();
            AutoManager manager = new AutoManager();

            return(DtoConverter.ConvertToDtos(manager.ListOfAutos));
        }
コード例 #3
0
        public AutoDto InsertAuto(AutoDto auto)
        {
            WriteActualMethod();
            AutoManager am = new AutoManager();

            return(am.Insert(auto.ConvertToEntity()).ConvertToDto());
        }
コード例 #4
0
        public AutoDto getCarById(int id)
        {
            WriteActualMethod();
            AutoManager autoManager = new AutoManager();

            return(DtoConverter.ConvertToDto(autoManager.getCarById(id)));
        }
コード例 #5
0
        public List <AutoDto> getAllCars()
        {
            WriteActualMethod();
            AutoManager autoManager = new AutoManager();

            return(DtoConverter.ConvertToDtos(autoManager.List));
        }
コード例 #6
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            ClienteVendedor nCliente = new ClienteVendedor();

            nCliente.sNombre     = txtNombre.Text;
            nCliente.sApellidos  = txtApellidos.Text;
            nCliente.sINE        = txtINE.Text;
            nCliente.sTelefono   = txtTelefono.Text;
            nCliente.sCalle      = txtCalle.Text;
            nCliente.sNumero     = txtNumero.Text;
            nCliente.sEntreCalle = txtEntre.Text;
            nCliente.sColonia    = txtColonia.Text;
            nCliente.sCiudad     = txtCiudad.Text;
            nCliente.sEstado     = txtEstado.Text;
            nCliente.sImagen     = ucFotoCliente.ImagenString;

            int pkCliente = ClienteVendedorManager.GuardarNuevoCV(nCliente);

            Auto nAuto = new Auto();

            nAuto.sFotoPrincipal  = ucFotoPrincipal.ImagenString;
            nAuto.sFotoSecundaria = ucFotoSecundaria.ImagenString;
            nAuto.sFotoTercearia  = ucFotoTercearia.ImagenString;

            nAuto.sMarca       = txtMarca.Text;
            nAuto.sModelo      = txtModelo.Text;
            nAuto.sNumeroSerie = txtNumeroSerie.Text;
            nAuto.iAnio        = Convert.ToInt32(txtAnio.Text);
            nAuto.sDescripcion = txtComentario.Text;

            AutoManager.GuardarNuevoAuto(nAuto, pkCliente);
            int x = 0;
        }
コード例 #7
0
 public AutoDto UpdateAuto(AutoDto autoDto)
 {
     WriteActualMethod();
     return(handlingOptimisticConcurrencyException <AutoDto>("UpdateAuto",
                                                             () => AutoManager.UpdateAuto(autoDto.ConvertToEntity()).ConvertToDto()
                                                             ));
 }
コード例 #8
0
        public override async Task <Empty> Delete(AutoDto request, ServerCallContext context)
        {
            AutoManager manager = new AutoManager();
            Auto        car     = request.ConvertToEntity();
            await manager.Delete(car);

            return(new Empty());
        }
コード例 #9
0
        public void removeCar(AutoDto autoDto)
        {
            WriteActualMethod();
            Auto        auto        = DtoConverter.ConvertToEntity(autoDto);
            AutoManager autoManager = new AutoManager();

            autoManager.removeCar(auto);
        }
コード例 #10
0
 public AutoDetailViewModel(IMessageDisplayer displayer)
 {
     ChangeAutoType(AutoKlasse);
     SaveAutoCommand = new RelayCommand <Window>(param => SaveAuto(param));
     CancelCommand   = new RelayCommand <Window>(param => Cancel(param));
     autoManager     = new AutoManager();
     this.displayer  = displayer;
 }
コード例 #11
0
        public AutoReservationService(Func <IAutoReservationResultCallback> callbackCreator)
        {
            autoManager        = new AutoManager();
            kundeManager       = new KundeManager();
            reservationManager = new ReservationManager();

            _createCallbackChannel = callbackCreator;
        }
コード例 #12
0
 public AutoViewModel(IMessageDisplayer displayer)
 {
     Autos             = new ObservableCollection <Auto>();
     AddNewAutoCommand = new RelayCommand <Auto>(param => SaveAuto(param));
     RemoveAutoCommand = new RelayCommand <Auto>(param => DeleteAuto(param));
     autoManager       = new AutoManager();
     this.displayer    = displayer;
 }
コード例 #13
0
        public void DeleteAutoTest()
        {
            AutoManager autoManager = new AutoManager();
            Auto        auto        = autoManager.Auto(1);

            autoManager.Delete(auto);
            autoManager.Auto(1);
        }
コード例 #14
0
        public override async Task <AutoDto> Insert(AutoDto request, ServerCallContext context)
        {
            AutoManager manager = new AutoManager();
            Auto        car     = request.ConvertToEntity();
            Auto        newcar  = await manager.Insert(car);

            return(newcar.ConvertToDto());
        }
コード例 #15
0
        public override async Task <AutoDto> GetById(GetAutoByIdRequest request, ServerCallContext context)
        {
            AutoManager manager = new AutoManager();
            Auto        auto    = await manager.GetById(request.Id);

            AutoDto result = auto.ConvertToDto();

            return(result);
        }
コード例 #16
0
        public void DeleteAutoOptimisticConcurrencyTest()
        {
            AutoManager autoManager = new AutoManager();
            Auto        auto        = new LuxusklasseAuto {
                Id = 3, Marke = "Tesla", Tagestarif = 320, Basistarif = 10
            };

            autoManager.Delete(auto);
        }
コード例 #17
0
        public override async Task <AutosDto> GetAll(Empty request, ServerCallContext context)
        {
            AutoManager manager = new AutoManager();
            List <Auto> allCars = await manager.GetAll();

            List <AutoDto> dtos     = allCars.ConvertToDtos();
            AutosDto       autosDto = new AutosDto();

            dtos.ForEach(autoDto => autosDto.Cars.Add(autoDto));
            return(autosDto);
        }
コード例 #18
0
 public void UpdateAuto(AutoDto auto)
 {
     try
     {
         AutoManager.Update(auto.ConvertToEntity());
     }
     catch (DbUpdateConcurrencyException)
     {
         var fault = new GenericFault("Update Concurrency Exception");
         throw new FaultException <GenericFault>(fault);
     }
 }
コード例 #19
0
        public void UpdateAutoTest()
        {
            AutoManager autoManager = new AutoManager();
            Auto        auto        = autoManager.Auto(1);

            auto.Marke      = "Fiat Multipla";
            auto.Tagestarif = 100;
            Auto updatedAuto = autoManager.Update(auto);

            Assert.AreEqual("Fiat Multipla", updatedAuto.Marke);
            Assert.AreEqual(100, updatedAuto.Tagestarif);
        }
コード例 #20
0
 public AutoDto GetAutoById(int id)
 {
     try
     {
         return(AutoManager.GetById(id).ConvertToDto());
     }
     catch (InvalidOperationException)
     {
         var fault = new GenericFault("Keine Gültige ID");
         throw new FaultException <GenericFault>(fault);
     }
 }
コード例 #21
0
        public void InsertAutoTest()
        {
            AutoManager autoManager = new AutoManager();
            Auto        auto        = new MittelklasseAuto {
                Marke = "Opel Corsa", Tagestarif = 100
            };
            Auto insertedAuto = autoManager.Insert(auto);

            Assert.AreEqual(4, insertedAuto.Id);
            Auto getAuto = autoManager.Auto(4);

            Assert.AreEqual("Opel Corsa", getAuto.Marke);
        }
コード例 #22
0
        public void AddReservationTest()
        {
            KundeManager km          = new KundeManager();
            AutoManager  am          = new AutoManager();
            Kunde        k1          = km.GetKundeById(1);
            Auto         a1          = am.GetAutoById(1);
            Reservation  reservation = new Reservation {
                KundeId = k1.Id, AutoId = a1.Id, Von = new DateTime(2018, 12, 24), Bis = new DateTime(2018, 12, 27)
            };

            Target.AddReservation(reservation);
            Assert.Equal(5, Target.GetReservations().Count);
        }
コード例 #23
0
        public override async Task <AllAutos> GetAll(Empty request, ServerCallContext context)
        {
            AutoManager manager  = new AutoManager();
            List <Auto> autoList = await manager.GetAll();

            AllAutos allAutoDto = new AllAutos();

            foreach (Auto k in autoList)
            {
                allAutoDto.Auto.Add(k.ConvertToDto());
            }
            return(allAutoDto);
        }
コード例 #24
0
        public override async Task <AutoDto> Get(AutoRequest request, ServerCallContext context)
        {
            AutoManager manager = new AutoManager();
            Auto        car     = await manager.Get(request.Id);

            if (car == null)
            {
                throw new RpcException(new Status(
                                           StatusCode.OutOfRange, "Id couldn't be found."
                                           ));
            }
            return(car.ConvertToDto());
        }
コード例 #25
0
        public override async Task <Empty> Delete(AutoDto request, ServerCallContext context)
        {
            try
            {
                AutoManager manager = new AutoManager();
                await manager.Delete(request.ConvertToEntity());

                return(new Empty());
            }
            catch (OptimisticConcurrencyException <Auto> e)
            {
                throw new RpcException(new Status(StatusCode.Aborted, e.Message));
            }
        }
コード例 #26
0
        public void UpdateAutoTest()
        {
            Auto myCar = AutoManager.GetAutoById(1);

            myCar.Marke      = "Marke";
            myCar.Tagestarif = 20;
            AutoManager.UpdateAuto(myCar);

            Auto sameCar = AutoManager.GetAutoById(1);

            Assert.Equal("Marke", myCar.Marke);
            Assert.Equal("Marke", sameCar.Marke);
            Assert.Equal(20, myCar.Tagestarif);
            Assert.Equal(20, sameCar.Tagestarif);
        }
コード例 #27
0
        public override async Task <AutoDto> Insert(AutoDto request, ServerCallContext context)
        {
            try
            {
                AutoManager manager = new AutoManager();
                Auto        auto    = await manager.Insert(request.ConvertToEntity());

                AutoDto result = auto.ConvertToDto();
                return(result);
            }
            catch (OptimisticConcurrencyException <Auto> e)
            {
                throw new RpcException(new Status(StatusCode.Aborted, e.Message));
            }
        }
コード例 #28
0
        public void InsertAndDeleteAutoTest()
        {
            Auto someCar = new LuxusklasseAuto
            {
                Marke      = "DUDE!",
                Tagestarif = 10,
                Basistarif = 20
            };

            Auto neu = AutoManager.InsertAuto(someCar);

            Auto sameCar = AutoManager.GetAutoById(neu.Id);

            Assert.Equal("DUDE!", someCar.Marke);
            Assert.Equal("DUDE!", sameCar.Marke);

            AutoManager.DeleteAuto(neu);
        }
コード例 #29
0
        public override async Task <Empty> Update(AutoDto request, ServerCallContext context)
        {
            AutoManager manager = new AutoManager();
            Auto        car     = request.ConvertToEntity();

            try
            {
                await manager.Update(car);
            }
            catch (OptimisticConcurrencyException <Auto> exception)
            {
                throw new RpcException(new Status(
                                           StatusCode.Aborted,
                                           "Conccurency Exception."
                                           ), exception.ToString());
            }
            return(new Empty());
        }
コード例 #30
0
        public void modifyCar(AutoDto autoDto)
        {
            WriteActualMethod();
            Auto        auto        = DtoConverter.ConvertToEntity(autoDto);
            AutoManager autoManager = new AutoManager();

            try
            {
                autoManager.modifyCar(auto);
            }
            catch (OptimisticConcurrencyException <Auto> e) {
                OptimisticConcurrency <AutoDto> fault = new OptimisticConcurrency <AutoDto>();
                fault.Result      = false;
                fault.Message     = e.Message;
                fault.Description = "Occurrency Exception!";

                throw new FaultException <OptimisticConcurrency <AutoDto> >(fault);
            }
        }