public async Task <IHttpActionResult> UpdateJobHandleCEAnalysis(int id, JobSplitCEAnalysis entity) { string userId = User.Identity.GetUserId(); var existingEntity = await context.JobSplitCEAnalysis.FindAsync(entity.Id); if (entity == null) { return(NotFound()); } if (id != entity.Id) { return(BadRequest(ModelState)); } if (entity == null) { var message = string.Format("Entry is empty"); HttpError err = new HttpError(message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err))); } if (existingEntity != null && context.Entry(existingEntity).State != EntityState.Detached) { context.Entry(existingEntity).State = EntityState.Detached; } var local = context.Set <JobSplitCEAnalysis>().Local.FirstOrDefault(f => f.Id == entity.Id); if (local != null) { context.Entry(local).State = EntityState.Detached; } existingEntity.IsJobHandleByCE = true; context.Entry(existingEntity).State = EntityState.Modified; await context.SaveChangesAsync(); var jobHandler = new JobHandler() { JobTrackerId = existingEntity.JobTrackerId, JobSplitId = existingEntity.JobSplitId, HandlerId = userId, CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, Remark = "CE" }; //Create JobHandle var tx = CreateJobHandler(jobHandler); return(Ok()); }
public async Task <IHttpActionResult> CreateJobSlitCEAnalysis(JobSplitCEAnalysis entity) { userId = User.Identity.GetUserId(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newEntity = entity; context.JobSplitCEAnalysis.Add(newEntity); await context.SaveChangesAsync(); return(Ok <JobSplitCEAnalysis>(newEntity)); }
public async Task <IHttpActionResult> UpdateQAWasteRequest(int id, JobSplitCEAnalysis entity) { string userId = User.Identity.GetUserId(); JobSplitCEAnalysis existingEntity = await context.JobSplitCEAnalysis.FindAsync(entity.Id); JobSplit jobSplit = await context.JobSplits.FindAsync(entity.JobSplitId); if (entity == null) { return(NotFound()); } if (id != entity.Id) { return(BadRequest(ModelState)); } if (entity == null) { var message = string.Format("Entry is empty"); HttpError err = new HttpError(message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err))); } if (existingEntity != null && context.Entry(existingEntity).State != EntityState.Detached) { context.Entry(existingEntity).State = EntityState.Detached; } var local = context.Set <JobSplitCEAnalysis>().Local.FirstOrDefault(f => f.Id == entity.Id); if (local != null) { context.Entry(local).State = EntityState.Detached; } context.JobSplitCEAnalysis.Attach(existingEntity); context.Entry(existingEntity).State = EntityState.Modified; await context.SaveChangesAsync(); return(Ok <JobSplitCEAnalysis>(existingEntity)); }
public async Task <IHttpActionResult> UpdateJobSlitCEAnalysis(int id, JobSplitCEAnalysis entity) { string userId = User.Identity.GetUserId(); var copiedEntity = entity; JobSplitCEAnalysis existingEntity = await context.JobSplitCEAnalysis.FindAsync(entity.Id); var jobSplit = await context.JobSplits.Include(a => a.JobTracker).FirstOrDefaultAsync(b => b.Id == entity.JobSplitId); if (entity == null) { return(NotFound()); } if (id != entity.Id) { return(BadRequest(ModelState)); } if (entity == null) { var message = string.Format("Entry is empty"); HttpError err = new HttpError(message); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err))); } if (existingEntity != null && context.Entry(existingEntity).State != EntityState.Detached) { context.Entry(existingEntity).State = EntityState.Detached; } var local = context.Set <JobSplitCEAnalysis>().Local.FirstOrDefault(f => f.Id == entity.Id); if (local != null) { context.Entry(local).State = EntityState.Detached; } // Analysis Computation var range = (jobSplit.RangeTo - jobSplit.RangeFrom) + 1; var quantityGood = range - (existingEntity.HeldReturned + (entity.QuantityBad + entity.QuantityHeld)); existingEntity.QuantityGood = quantityGood; existingEntity.QuantityBad = entity.QuantityBad; existingEntity.QuantityHeld = entity.QuantityHeld; existingEntity.ModifiedById = userId; existingEntity.ModifiedOn = DateTime.Now; existingEntity.IsCEInitialized = true; context.JobSplitCEAnalysis.Attach(existingEntity); context.Entry(existingEntity).State = EntityState.Modified; await context.SaveChangesAsync(); // Update the JobTracker var jobStatusWIP = _repo.FindJobStatusByName("WIP"); var jobStatusPending = _repo.FindJobStatusByName("Pending"); var jobStatusCompleted = _repo.FindJobStatusByName("Completed"); var jobStatusQueue = _repo.FindJobStatusByName("Queue"); var jobStatusNotRequired = _repo.FindJobStatusByName("Not Required"); var job = await context.Jobs.FindAsync(jobSplit.JobTracker.JobId); var jobTracker = await context.JobTrackers.FindAsync(jobSplit.JobTracker.Id); var jobTypePersoOnly = _repo.FindJobTypeByName("Perso Only"); var jobTypePrintingOnly = _repo.FindJobTypeByName("Printing Only"); var jobTypePrintingAndPerso = _repo.FindJobTypeByName("Printing And Perso"); var jobTypePrintingPersoAndMailing = _repo.FindJobTypeByName("Printing, Perso And Mailing"); var jobTypePersoAndMailing = _repo.FindJobTypeByName("Perso And Mailing"); var serviceType = job.ServiceTypeId; jobTracker.CardEngrResumeId = jobStatusWIP.Id; if (copiedEntity.IsCEInitialized == false) { } // JobServiceType Tracker Update #region JobTrackerUpdateFlow if (serviceType == jobTypePersoOnly.Id) { jobTracker.QCId = jobStatusQueue.Id; } else if (serviceType == jobTypePrintingAndPerso.Id) { jobTracker.QCId = jobStatusQueue.Id; } else if (serviceType == jobTypePersoAndMailing.Id) { jobTracker.QCId = jobStatusQueue.Id; } else if (serviceType == jobTypePrintingPersoAndMailing.Id) { jobTracker.QCId = jobStatusQueue.Id; } #endregion jobTracker.ModifiedOn = DateTime.Now; context.Entry(jobTracker).State = EntityState.Modified; await context.SaveChangesAsync(); return(Ok <JobSplitCEAnalysis>(entity)); }
public async Task <IHttpActionResult> CreateFirstCard(IList <FirstCardModel> entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } userId = User.Identity.GetUserId(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var jobTypePersoOnly = _repo.FindJobTypeByName("Perso Only"); var jobTypePrintingOnly = _repo.FindJobTypeByName("Printing Only"); var jobTypeMailingOnly = _repo.FindJobTypeByName("Mailing Only"); var jobTypePrintingAndPerso = _repo.FindJobTypeByName("Printing And Perso"); var jobTypePrintingPersoAndMailing = _repo.FindJobTypeByName("Printing, Perso And Mailing"); var jobTypePersoAndMailing = _repo.FindJobTypeByName("Perso And Mailing"); var departmentCE = _repo.FindDepartmentByName("Card Engineer"); var departmentQc = _repo.FindDepartmentByName("Quality Control"); var departmentMa = _repo.FindDepartmentByName("Mailing"); var departmentDp = _repo.FindDepartmentByName("Dispatch"); var jobStatusCompleted = _repo.FindJobStatusByName("Completed"); var jobStatusQueue = _repo.FindJobStatusByName("Queue"); var jobTracker = await context.JobTrackers.FindAsync(entity[0].JobTrackerId); var job = await context.Jobs.FindAsync(jobTracker.JobId); var serviceType = job.ServiceTypeId; var newFirstCard = new Sid03FirstCard() { JobTrackerId = entity[0].JobTrackerId, InitializedById = userId, InitializedOn = DateTime.Now }; context.Sid03FirstCards.Add(newFirstCard); await context.SaveChangesAsync(); // Create the JobSplit #region JobSplitAnalysis foreach (var m in entity) { var newJobSlit = new JobSplit() { JobTrackerId = m.JobTrackerId, DepartmentId = m.DepartmentId, SidMachineId = m.SidMachineId, RangeFrom = m.RangeFrom, RangeTo = m.RangeTo, CreatedById = userId, CreatedOn = DateTime.Now }; var t1 = await CreateJobSlit(newJobSlit); var lastTestMe = newJobSlit.Id; var lastJobSplit = _repository.JobSplits.OrderByDescending(x => x.Id).Take(1).ToList(); // Create the QA Process var newQA = new Sid05QA() { JobTrackerId = m.JobTrackerId, JobSplitId = lastJobSplit[0].Id, CreatedOn = DateTime.Now, CreatedById = userId }; var t2 = await CreateSidQA(newQA); // Create the CEAnalysis var goodQty = (m.RangeTo - m.RangeFrom) + 1; var newJobSlitCEAnalysis = new JobSplitCEAnalysis() { JobSplitId = lastJobSplit[0].Id, JobTrackerId = m.JobTrackerId, QuantityGood = goodQty, QuantityBad = 0, QuantityHeld = 0, CreatedOn = DateTime.Now, CreatedById = userId, ModifiedById = userId, ModifiedOn = DateTime.Now }; var t3 = await CreateJobSlitCEAnalysis(newJobSlitCEAnalysis); } #endregion //// Update JobTracker #region JobTrackerUpdateFlow jobTracker.FirstJobRunId = jobStatusCompleted.Id; if (serviceType == jobTypePersoOnly.Id) { jobTracker.QAId = jobStatusQueue.Id; } else if (serviceType == jobTypePrintingAndPerso.Id) { jobTracker.QAId = jobStatusQueue.Id; } else if (serviceType == jobTypePersoAndMailing.Id) { jobTracker.QAId = jobStatusQueue.Id; } else if (serviceType == jobTypePrintingPersoAndMailing.Id) { jobTracker.QAId = jobStatusQueue.Id; } jobTracker.ModifiedOn = DateTime.Now; context.Entry(jobTracker).State = EntityState.Modified; await context.SaveChangesAsync(); #endregion return(Ok <Sid03FirstCard>(newFirstCard)); }