Пример #1
0
        public IActionResult BookVehicle(string type, string issue, string cosmetic, string resolution, string labour, string bay, string customerID, string vrm, string mechanic)
        {
            if (!isAuthenticated())
            {
                return(RedirectToAction("Login", "Auth"));
            }

            JobNote estimate = new JobNote
            {
                id   = JobProvider.GetUniqueKey(255),
                type = "Estimate",
                body = "Issue: " + issue + " Cosmetic Condition: " + cosmetic + " Proposed Resolution: " + resolution,
                time = DateTime.Now,
                user = UserProvider.getUserFromUsername(HttpContext.Session.GetString("user"))
            };

            JobNote labourEstimate = new JobNote
            {
                id   = JobProvider.GetUniqueKey(255),
                type = "Labour Estimate",
                body = labour,
                time = DateTime.Now,
                user = UserProvider.getUserFromUsername(HttpContext.Session.GetString("user"))
            };

            List <JobNote> notes = new List <JobNote>();

            notes.Add(estimate);
            notes.Add(labourEstimate);

            Job job = new Job
            {
                jobID    = JobProvider.GetUniqueNumber(8),
                start    = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day),
                end      = null,
                paid     = null,
                bay      = Int32.Parse(bay),
                status   = "Ongoing",
                type     = type,
                customer = CustomerProvider.getCustomerFromID(customerID),
                vehicle  = VehicleProvider.getVehicleFromVRM(vrm),
                notes    = notes,
                labour   = new Dictionary <string, float>(),
                mechanic = UserProvider.getUserFromUsername(mechanic)
            };

            JobProvider.createJob(job);

            TempData["JobID"] = job.jobID;

            return(RedirectToAction("ViewJob", new { id = job.jobID }));
        }