예제 #1
0
        public ActionResult Delete(string id)
        {
            VehicleServiceClient vsc = new VehicleServiceClient();

            vsc.delete(vsc.get(id));
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Index()
        {
            VehicleServiceClient vsc = new VehicleServiceClient();

            ViewBag.listVehicles = vsc.getall();
            return(View());
        }
예제 #3
0
        public ActionResult Create(VehicleViewModel vvm)
        {
            VehicleServiceClient vsc = new VehicleServiceClient();

            vsc.create(vvm.Vehicle);
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public ActionResult GetAllVehicle()
        {
            dynamic vehicle = 0;

            try
            {
                if (ModelState.IsValid)
                {
                    VehicleServiceClient vehicleServiceClient = new VehicleServiceClient();
                    vehicle = vehicleServiceClient.GetAllVehicle();
                    //if (vehicle.Count == 0 || vehicle == null)
                    //{
                    //    ModelState.AddModelError("error", "No Record Found");
                    //}
                }
            }
            // Please through Exeption Everywhere
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Wrong");
                vehicle = null;
                throw e;
            }
            return(Json(vehicle, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _client = new VehicleServiceClient();
            _table  = new DataTable();
            _table.Columns.Add("Id");
            _table.Columns.Add("Título");
            _table.Columns.Add("Nombre");
            _table.Columns.Add("Teléfono");
            _table.Columns.Add("Precio");

            LoadVehicles();
        }
 public VehicleViewModel()
 {
     _vehicleServiceClient = new VehicleServiceClient();
     _driverServiceClient  = new DriverServiceClient();
     LoadVehicles();
     RefreshCommand = new RelayCommand(OnRefresh);
     NewCommand     = new RelayCommand(OnNew);
     EditCommand    = new RelayCommand(OnEdit, CanEdit);
     CopyCommand    = new RelayCommand(OnCopy, CanCopy);
     DeleteCommand  = new RelayCommand(OnDelete, CanDelete);
     SaveCommand    = new RelayCommand(OnSave, CanSave);
     OnNew();
 }
예제 #7
0
        public ActionResult Index(string startDate, string endDate, string locationAndEpc, string user, string itemsPerPage)
        {
            int                  format         = 0;
            bool                 inputError     = false;
            DateTime             start          = new DateTime();
            DateTime             end            = new DateTime();
            VehicleServiceClient vehicleService = new VehicleServiceClient();

            string[] locationEpcArray = locationAndEpc.Split('*');
            string   location         = locationEpcArray[0];
            String   locationEPC      = locationEpcArray[1];

            bool authenticated = vehicleService.AuthenticateUser(user);

            //ViewBags
            ViewBag.start = startDate;
            ViewBag.end   = endDate;
            ViewBag.locc  = locationAndEpc;
            ViewBag.epc   = locationEPC;
            ViewBag.usr   = user;

            vehiclePassageList.Clear();

            //Checks if itemsPerPage, startDate or endDate are in the wrong format
            if (Int32.TryParse(itemsPerPage, out format) == false || DateTime.TryParse(startDate, out start) == false || DateTime.TryParse(endDate, out end) == false)
            {
                //if any of them are, sets format to -1 which will cause a responseCode 2, resulting in an error
                inputError = true;
                format     = 1;
            }
            else
            {
                format = Convert.ToInt32(itemsPerPage);
            }


            // fullXmlAnswer = vehicleService.XmlAnswer(start, end, locationEPC, location, user, authenticated);
            fullXmlAnswer = vehicleService.XmlAnswer(start, end, locationEPC, location, user, authenticated, inputError);


            foreach (XElement vehiclePassage in fullXmlAnswer.Descendants("FordonPassage"))
            {
                vehiclePassageList.Add(new VehiclePassage(vehiclePassage));
            }



            return(RedirectToAction("SearchResults", new { size = format }));
        }
예제 #8
0
        public ActionResult Delete(int id)
        {
            Vehicles vehicle = new Vehicles();

            try
            {
                if (ModelState.IsValid)
                {
                    VehicleServiceClient vehicleServiceClient = new VehicleServiceClient();
                    vehicle = vehicleServiceClient.GetVehicles(id);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong");
                vehicle = null;
                throw e;
            }
            return(View(vehicle));
        }
예제 #9
0
        public ActionResult DeleteVehicle(int id)
        {
            bool status = false;

            try
            {
                if (ModelState.IsValid)
                {
                    VehicleServiceClient vehicleServiceClient = new VehicleServiceClient();
                    status = vehicleServiceClient.Delete(id);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong!");
                status = false;
                throw e;
            }
            return(View("Index"));
            // return new JsonResult { Data = new { status = status } };
        }
예제 #10
0
        public ActionResult PassGriddata(List <Vehicles> griddata)
        {
            bool status = false;

            try
            {
                if (ModelState.IsValid)
                {
                    VehicleServiceClient vehicleServiceClient = new VehicleServiceClient();
                    status = vehicleServiceClient.GriddataService(griddata);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong");
                status = false;
                throw e;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
예제 #11
0
        public ActionResult Save(Vehicles vehicle)
        {
            bool status = false;

            try
            {
                if (ModelState.IsValid)
                {
                    VehicleServiceClient vehicleServiceClient = new VehicleServiceClient();
                    status = vehicleServiceClient.SaveData(vehicle);
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong");
                status = false;
                throw e;
            }
            return(View());
            // return new JsonResult { Data = new { status = status } };
        }
예제 #12
0
        static void Main(string[] args)
        {
            VehicleServiceClient client = new VehicleServiceClient("Ws");

            try
            {
                #region ADD NEW CAR
                Car newCar = new Car
                {
                    Id         = 6,
                    Wheels     = 4,
                    MotorPower = 400,
                    NbrOfDoors = 2,
                    Model      = "Tesla Sportscar"
                };
                client.ByCar(newCar);
                #endregion

                #region ADD NEW MOTORCYCLE
                Motorcycle newMotorcycle = new Motorcycle
                {
                    Id         = 6,
                    Wheels     = 2,
                    MotorPower = 500,
                    Type       = "Chopper",
                };
                client.ByMotorcycle(newMotorcycle);
                #endregion

                #region GET CARS
                Console.WriteLine("\nList Of Cars");
                var carResult = client.GetCars();
                foreach (var item in carResult)
                {
                    Console.WriteLine($"ID: {item.Id} - WHEELS: {item.Wheels} - MOTORPOWER: {item.MotorPower} - NUMBER OF DOORS: {item.NbrOfDoors} - MODEL: {item.Model}");
                }
                #endregion

                #region GET MOTORCYCLES
                Console.WriteLine("\nList Of MotorCycle");
                var motorcycleResult = client.GetMotorcycles();
                foreach (var item in motorcycleResult)
                {
                    Console.WriteLine($"ID: {item.Id} - WHEELS: {item.Wheels} - MOTORPOWER: {item.MotorPower} - TYPE: {item.Type}");
                }
                #endregion

                #region SELL CAR
                Console.WriteLine("\nSold Cars");
                var soldCar = client.SellCar(1);
                Console.WriteLine($"ID: {soldCar.Id} - WHEELS: {soldCar.Wheels} - MOTORPOWER: {soldCar.MotorPower} - NUMBER OF DOORS: {soldCar.NbrOfDoors} - MODEL: {soldCar.Model}");
                #endregion

                #region SELL MOTORCYCLE
                Console.WriteLine("\nSold Motorcycle");
                var soldMotorcycle = client.SellMotorcycle(2);
                Console.WriteLine($"ID: {soldMotorcycle.Id} - WHEELS: {soldMotorcycle.Wheels} - MOTORPOWER: {soldMotorcycle.MotorPower} - TYPE: {soldMotorcycle.Type}");
                #endregion

                Console.ReadLine();

                /* ------------------------------------------------------------------ */

                #region GET CARS
                Console.WriteLine("\nNew List Of Cars");
                var newCarResult = client.GetCars();
                foreach (var item in newCarResult)
                {
                    Console.WriteLine($"ID: {item.Id} - WHEELS: {item.Wheels} - MOTORPOWER: {item.MotorPower} - NUMBER OF DOORS: {item.NbrOfDoors} - MODEL: {item.Model}");
                }
                #endregion

                #region GET MOTORCYCLES
                Console.WriteLine("\nNew List Of MotorCycle");
                var newMotorcycleResult = client.GetMotorcycles();
                foreach (var item in newMotorcycleResult)
                {
                    Console.WriteLine($"ID: {item.Id} - WHEELS: {item.Wheels} - MOTORPOWER: {item.MotorPower} - TYPE: {item.Type}");
                }
                #endregion

                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
예제 #13
0
        public override void Setup()
        {
            base.Setup();

            _sut = new VehicleServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null);
        }
예제 #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _client = new VehicleServiceClient();
 }