public ActionResult Search(VehicleSearchRequest request)
        {
            ViewData["resultArea"] = "Policy";
            ViewData["resultController"] = "VehicleAlert";
            ViewData["resultAction"] = "List";

            ViewData["vinNumber"] = request.VinNumber;
            ViewData["chassisNumber"] = request.ChassisNumber;
            ViewData["engineNumber"] = request.EngineNumber;
            ViewData["registrationNumber"] = request.RegistrationNumber;
            ViewData["initials"] = request.Initials;
            ViewData["lastName"] = request.LastName;
            ViewData["limit"] = request.Limit;

            var vehicleSvc = new VehicleLogic(Ticket);
            var results = vehicleSvc.Search(request);

            if (results.Rows.Count == 1)
            {
                int vehicleId = results.Rows[0].Get<int>("Id");
                return RedirectToAction("Display", new { id = vehicleId });
            }

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

            return View();
        }
        public ActionResult DisplayVehicle(int id)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            ViewData.Model = vehicleSvc.GetSummary(id);

            return View();
        }
        public ActionResult Create(FormCollection form)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var modelSvc = new ModelLogic(Ticket);

            var modelId = StringUtility.ToInt(form["modelId"]);
            var modelObj = modelSvc.GetById(modelId);

            var vehicleObj = new VehicleEntity();
            vehicleObj.VinNumber = form["vinNumber"];
            vehicleObj.ChassisNumber = form["chassisNumber"];
            vehicleObj.EngineNumber = form["engineNumber"];
            vehicleObj.WholesaleDate = StringUtility.ToDateTime(form["wholesaleDate"]);
            if (modelObj != null)
            {
                vehicleObj.Model.Id = modelObj.Id;
                vehicleObj.Model.Code = modelObj.Code;
                vehicleObj.Model.Name = modelObj.Name;
            }
            vehicleObj.CurrentDistance = int.Parse(form["currentDistance"]);

            int id = vehicleSvc.Create(vehicleObj);

            return RedirectToAction("Display", new { id = id });
        }
        public ActionResult CreateRetail(int id, FormCollection form)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var vehicleMsg = vehicleSvc.GetModel(id, false);

            BindVehicleRetail(ref vehicleMsg, form);

            vehicleSvc.CreateModel(vehicleMsg);

            return RedirectToAction("Display", new { id = id });
        }
        public ActionResult CreateRetail(int id)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var vehicleMsg = vehicleSvc.GetModel(id, false);

            ViewData.Model = vehicleMsg;
            ViewData["languageId"] = BuildLanguageList(vehicleMsg.Customer.Language.Id);
            ViewData["genderId"] = BuildGenderList(vehicleMsg.Customer.Gender.Id);
            ViewData["vehicleStatusId"] = BuildVehicleStatusList(vehicleMsg.Vehicle.VehicleStatus.Id);

            return View();
        }
        public ActionResult Display(int id)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var policySvc = new PolicyLogic(Ticket);

            var policyObj = policySvc.GetById(id);
            var vehicleObj = vehicleSvc.GetById(policyObj.VehicleId);

            ViewData.Model = policyObj;
            ViewData["vehicle"] = vehicleObj;

            return View();
        }
        public void Cancel(ClaimWorkflowModel model)
        {
            using (var db = CreateCatalog())
            {
                var claimObj = db.Claims.GetById(model.Id);
                var statusObj = db.ClaimStatuses.GetByCode("CANC");

                claimObj.ClaimStatus.Id = statusObj.Id;
                db.Claims.Update(claimObj);

                db.ClaimHistory.Create(claimObj.Id, statusObj.Id);

                if (!string.IsNullOrWhiteSpace(model.Comment))
                {
                    var vehicleSvc = new VehicleLogic(Ticket);
                    vehicleSvc.AddNote(claimObj.PolicyId, claimObj.Id, model.Comment);
                }
            }
        }
        public void Invoice(WarrantyClaimInvoiceModel model)
        {
            using (var db = CreateCatalog())
            {
                var claimObj = db.Claims.GetById(model.Id);
                var statusObj = db.ClaimStatuses.GetByCode("INV");

                claimObj.InvoiceNumber = model.InvoiceNumber;
                claimObj.RepairDate = model.RepairDate;
                claimObj.ClaimStatus.Id = statusObj.Id;
                db.Claims.Update(claimObj);

                db.ClaimHistory.Create(claimObj.Id, statusObj.Id);

                if (!string.IsNullOrWhiteSpace(model.Comment))
                {
                    var vehicleSvc = new VehicleLogic(Ticket);
                    vehicleSvc.AddNote(claimObj.PolicyId, claimObj.Id, model.Comment);
                }
            }
        }
        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();
        }
        public ActionResult Display(int id)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var msg = vehicleSvc.GetModel(id, true);
            ViewData.Model = msg;

            if (msg.Vehicle.CustomerId == 0)
            {
                return View("Display");
            }
            else
            {
                return View("DisplayRetail");
            }
        }
        public ActionResult Edit(int id)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var vehicleObj = vehicleSvc.GetById(id);

            ViewData.Model = vehicleObj;
            ViewData["vehicleStatusId"] = BuildVehicleStatusList(vehicleObj.VehicleStatus.Id);

            return View();
        }
        public ActionResult DisplayNotes(int id)
        {
            var vehicleSvc = new VehicleLogic(Ticket);
            var results = vehicleSvc.ListNotes(id);

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

            return View();
        }
        public void Reject(WarrantyClaimRejectModel model)
        {
            using (var db = CreateCatalog())
            {
                var claimObj = db.Claims.GetById(model.Id);
                var statusObj = db.ClaimStatuses.GetByCode("REJ");

                claimObj.RejectionReason.Id = model.RejectionReason.Id;
                claimObj.ClaimStatus.Id = statusObj.Id;
                db.Claims.Update(claimObj);

                db.ClaimHistory.Create(claimObj.Id, statusObj.Id);

                if (!string.IsNullOrWhiteSpace(model.Comment))
                {
                    var vehicleSvc = new VehicleLogic(Ticket);
                    vehicleSvc.AddNote(claimObj.PolicyId, claimObj.Id, model.Comment);
                }
            }
        }