public async Task <ActionResult <JobResponseModel> > Schedule(JobCreateRequestModel model) { var services = await this.garageService.Services(model.DepartmentId); JobScheduleData scheduleJobModel = new JobScheduleData() { CreatedByEmployeeId = this.currentEmployeeService.CurrentEmployeeId, CreateByEmployeeName = this.currentEmployeeService.EmployeeName, DeadLine = DateTime.UtcNow, DepartmentId = model.DepartmentId, PurchasedServices = services.Where(x => model.PurchasedServices.Contains(x.Id)).Select(s => new PurchasedServiceModel() { Name = s.Name, Id = s.Id, Price = s.Price, }), VehicleId = model.VehicleId, }; JobResponseModel scheludeJob = await jobSchedulerService.Schedule( scheduleJobModel, this.currentEmployeeService.GarageRole.ToString(), this.currentEmployeeService.CurrentGarageId.ToString(), this.currentEmployeeService.CurrentEmployeeId.ToString(), this.currentEmployeeService.EmployeeName); return(Created(nameof(Schedule), scheludeJob)); }
public void TestBooleanFlagsFromJobStatus() { var status = new JobResponseModel { JobStatus = "Pending" }; Assert.That(status.JobPending); Assert.That(!(status.JobCompletedOk || status.JobCompletedWithErrors || status.JobStarted || status.InvalidJob)); status.JobStatus = "Started"; Assert.That(status.JobStarted); Assert.That(!(status.JobCompletedOk || status.JobCompletedWithErrors || status.JobPending || status.InvalidJob)); status.JobStatus = "CompletedOk"; Assert.That(status.JobCompletedOk); Assert.That(!(status.JobStarted || status.JobCompletedWithErrors || status.JobPending || status.InvalidJob)); status.JobStatus = "TransactionError"; Assert.That(status.JobCompletedWithErrors); Assert.That(!(status.JobStarted || status.JobCompletedOk || status.JobPending || status.InvalidJob)); status.JobStatus = "NotRegistered"; Assert.That(status.InvalidJob); Assert.That(!(status.JobStarted || status.JobCompletedOk || status.JobPending || status.JobCompletedWithErrors)); status.JobStatus = "Unknown"; Assert.That(status.JobCompletedWithErrors); Assert.That(!(status.JobStarted || status.JobCompletedOk || status.JobPending || status.InvalidJob)); }
public async Task <JobResponseModel> Schedule(JobScheduleData model) { Job job = new Job() { CreatedDate = DateTime.UtcNow, CreatedByEmployeeId = model.CreatedByEmployeeId, CreateByEmployeeName = model.CreateByEmployeeName, DeadLine = DateTime.UtcNow, DepartmentId = model.DepartmentId, JobStatus = JobStatus.Pending, VehicleId = model.VehicleId, }; job.PurchasedServices = model.PurchasedServices.Select(ps => new JobService() { Name = ps.Name, Price = ps.Price, ServiceId = ps.Id }).ToList(); this.dbContext.Add(job); await this.dbContext.SaveChangesAsync(); var scheduledJob = new JobResponseModel() { AssignedEmployeeId = job.AssignedEmployeeId, CreatedByEmployeeId = job.CreatedByEmployeeId, CreateByEmployeeName = job.CreateByEmployeeName, AssignedEmployeeName = job.AssignedEmployeeName, CreatedDate = job.CreatedDate, DeadLine = job.DeadLine, DepartmentId = job.DepartmentId, FinishedDate = job.FinishedDate, Id = job.Id, JobStatus = job.JobStatus, PurchasedServices = job.PurchasedServices.Select(s => new PurchasedServiceModel() { Name = s.Name, Price = s.Price, Id = s.ServiceId, }), StratedDate = job.StratedDate, VehicleId = job.VehicleId, }; return(scheduledJob); }
public async Task <ActionResult <JobResponseModel> > GetJob(int id) { var job = await _context.Jobs .Include(p => p.Renter) .Include(p => p.Freelancer) .Include(p => p.Form) .Include(p => p.Type) .Include(p => p.JobSkills).ThenInclude(p => p.Skill) .Include(p => p.S).ThenInclude(p => p.Service) .Include(p => p.S).ThenInclude(p => p.Specialty) .Include(p => p.Payform) .Include(p => p.JobSkills).ThenInclude(p => p.Skill) .Include(p => p.Province) .SingleOrDefaultAsync(p => p.Id == id); if (job == null) { return(NotFound()); } var jobresponse = new JobResponseModel(job); return(jobresponse); }