public ActionResult Edit(int id)
        {
            var vehicleServiceSvc = new VehicleServiceLogic(Ticket);
            ViewData.Model = vehicleServiceSvc.GetById(id);

            return View();
        }
        public ActionResult Create(int id, FormCollection form)
        {
            var vehicleServiceSvc = new VehicleServiceLogic(Ticket);
            var dealerSvc = new DealerLogic(Ticket);

            var dealerId = StringUtility.ToInt(form["dealerId"]);
            var dealerObj = dealerSvc.GetById(dealerId);

            var serviceObj = new VehicleServiceEntity();
            serviceObj.VehicleId = id;
            if (dealerObj != null)
            {
                serviceObj.Dealer.Id = dealerObj.Id;
                serviceObj.Dealer.Code = dealerObj.Code;
                serviceObj.Dealer.Name = dealerObj.Name;
            }
            serviceObj.ServiceDate = StringUtility.ToDateTime(form["serviceDate"]);
            serviceObj.ServiceDistance = int.Parse(form["serviceDistance"]);
            serviceObj.InvoiceNumber = form["invoiceNumber"];

            vehicleServiceSvc.Save(serviceObj);

            DisplayInformation(string.Format("Vehicle service ({0}) has been successfully created.", serviceObj.ServiceDistance));

            var addMore = (form["addMore"] == "on");
            if (addMore)
            {
                return RedirectToAction("Create", new { id = id });
            }
            else
            {
                return RedirectToAction("List", new { id = id });
            }
        }
        public ActionResult Delete(int id)
        {
            var vehicleServiceSvc = new VehicleServiceLogic(Ticket);

            var serviceObj = vehicleServiceSvc.GetById(id);
            vehicleServiceSvc.Delete(id);

            DisplayInformation(string.Format("Vehicle service ({0}) has been successfully deleted.", serviceObj.ServiceDistance));
            TempData["vehicleService_deleteId"] = id;

            return RedirectToAction("List", new { id = serviceObj.VehicleId });
        }
        public ActionResult Undo(int id)
        {
            var vehicleServiceSvc = new VehicleServiceLogic(Ticket);

            var serviceObj = vehicleServiceSvc.GetById(id);
            vehicleServiceSvc.Reinstate(id);

            DisplayInformation(string.Format("Vehicle service ({0}) has been successfully reinstated.", serviceObj.ServiceDistance));

            return RedirectToAction("List", new { id = serviceObj.VehicleId });
        }
        public ActionResult List(int id)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var vehicleServiceSvc = new VehicleServiceLogic(Ticket);

            ViewData.Model = vehicleServiceSvc.GetByVehicle(id);
            ViewData["vehicle"] = vehicleSvc.GetById(id);
            ViewData["deleteId"] = TempData["vehicleService_deleteId"] ?? 0;

            return View();
        }
Exemplo n.º 6
0
        public ActionResult DisplayServiceHistory(int id)
        {
            var serviceSvc = new VehicleServiceLogic(Ticket);
            var results = serviceSvc.GetByVehicle(id);

            ViewData.Model = results;
            ViewData.Add("resultsCount", results.Count);

            return View();
        }