예제 #1
0
        public void ShouldAddVehicle()
        {
            var vehicleRequestModel = new VehicleRequestModel {
                Brand = "brand", PricePerDay = 10, Year = 2021
            };

            var response = vehicleService.Add(vehicleRequestModel);

            vehicleRepositoryMock.Verify(x => x.Add(It.IsAny <Vehicle>()), Times.Once);
            repositoryMock.Verify(x => x.Save(), Times.Once);
            Assert.False(response.HasErrors());
            Assert.AreEqual(response.Messages.Count(x => x.Code == Constants.VEHICLE_SAVED), 1);
        }
        public void Index()
        {
            VehicleService vehicleService = new VehicleService();

            //Verificar cadastros do Seed
            var result = vehicleService.GetAll();

            Assert.IsNotNull(result);
            var numberOfRecords = result.ToList().Count;

            Assert.AreEqual(1, numberOfRecords);

            //Verificar cadastro de veículo
            VehicleModel model = new VehicleModel
            {
                Brand       = "Chevrolet",
                Color       = "Preto",
                Model       = "Corsa",
                Year        = 1999,
                Price       = 2000,
                Isnew       = false,
                Description = "Chevrolet corsa preto"
            };

            vehicleService.Add(model);

            //Verificar exclusão
            result = vehicleService.GetAll();
            var last = result.Last();

            vehicleService.Remove(last.Id);
            Assert.AreEqual(1, numberOfRecords);
        }
예제 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var obj = new VEHICLE();

            obj.VEHICLE_REGNO  = popTxtReg.Text;
            obj.VEHICLE_CODE   = popTxtCode.Text;
            obj.VEHICLE_TYPENO = popTxtTypNO.Text;
            var cmd = new VehicleService(obj);

            if (flag.Text.Equals("Add"))
            {
                obj.Action             = ActionEnum.Create;
                obj.CREATE_DATE        = DateTime.Now;
                obj.CREATE_EMPLOYEE_ID = 0;
                obj.UPDATE_DATE        = DateTime.Now;
                obj.UPDATE_EMPLOYEE_ID = 0;
                obj.SYE_DEL            = true;
                cmd.Add();
            }
            else
            {
                obj.Action             = ActionEnum.Update;
                obj.VEHICLE_ID         = Convert.ToInt32(ViewState["VehicleID"].ToString());
                obj.UPDATE_DATE        = DateTime.Now;
                obj.UPDATE_EMPLOYEE_ID = 0;
                obj.SYE_DEL            = true;
                cmd.Edit();
            }
            ViewState["VehicleID"] = null;
            Response.Redirect("SearchVehicle.aspx");
        }
예제 #4
0
 public async Task <IHttpActionResult> Post(VehicleModel vehicle)
 {
     try
     {
         if (!vehicle.Validate())
         {
             return(BadRequest("Las propiedades del vehiculo no son correctas"));
         }
         using (VehicleService Service = new VehicleService())
         {
             if (await Service.Add(vehicle))
             {
                 return(Created <VehicleModel>("", vehicle));
             }
             else
             {
                 return(BadRequest());
             }
         }
     }
     catch (Exception ex)
     {
         return(new HttpActionResult(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
예제 #5
0
 public void AddTest()
 {
     using (VehicleService service = new VehicleService())
     {
         bool Ok = service.Add(vehicle).Result;
         Assert.IsTrue(Ok);
     }
 }
예제 #6
0
 public ActionResult Create(Vehicle vehicle)
 {
     try
     {
         Response resp = VehicleService.Add(vehicle);
         ViewBag.Response = resp;
         DropdownViewBag();
         return(View());
     }
     catch
     {
         DropdownViewBag();
         return(View());
     }
 }
예제 #7
0
 public ActionResult Create(Vehicle vehicle)
 {
     try
     {
         var response = VehicleService.Add(vehicle);
         ViewBag.Response = response;
     }
     catch
     {
         ViewBag.Response = Domain.DTOs.Response.Fail("Bir hata oluştu");
     }
     finally
     {
         SetParametersToViewBag();
     }
     return(View());
 }
        public IActionResult Create([FromForm] NewVehicleViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_Create", new NewVehicleViewModel()));
            }

            try
            {
                vehicleService.Add(viewModel.Name,
                                   viewModel.Type,
                                   viewModel.RegistrationNumber,
                                   viewModel.MaximCarryWeight,
                                   viewModel.VIN);
                return(PartialView("_Create", new NewVehicleViewModel()));
            }
            catch (Exception e)
            {
                logger.LogError("Failed to create a new vehicle {@Exception}", e.Message);
                logger.LogDebug("Failed to create a new vehicle {@ExceptionMessage}", e);
                return(BadRequest(e.Message));
            }
        }
 public Task Put(string id)
 => _vehicleService.Add(id);
 public ActionResult Create(Vehicle v, HttpPostedFileBase file)
 {
     vs.Add(v);
     vs.Commit();
     return(RedirectToAction("Vehicles"));
 }
 public static Task SubscribeEvents(this IServiceBusListenerFactory serviceBus, VehicleService vehicleService)
 => serviceBus.Create().SubscribeVehicleTrackSubscribe(t => vehicleService.Add(t.Ids));