//public ActionResult AssignJob() //{ // var priorityJob = (Job)_jobQueueService.PriorityQue.Dequeue(); // var takerId = (int)(Session[Constants.TakerId]); // priorityJob.AssignedToId = takerId; // priorityJob.Status = Req.Enums.JobStatus.Assigned; // _jobBLL.UpdateJob(priorityJob); // var jobs = _jobBLL.GetJobsByTakerId(takerId).ToList(); // return View("ViewJobs", jobs); //} public ActionResult EditJobForStakeHolder(int jobId) { var job = _jobBLL.GetJobById(jobId); var stakeHolderId = (int)(Session[Constants.StakeHolderId]); var stakeHolder = _stakeHolderBLL.GetStakeHolderById(stakeHolderId); //var filePath = _fileBLL.GetFolderPath(job.JobId); //if (Directory.Exists(filePath)) //{ // files = Directory.GetFiles(filePath); //} var folderPath = _fileBLL.GetFolderPath(job.JobId); string[] files = null; try { files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories) != null?Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories) : null; } catch { } var model = new UpdateStakeHolderJobViewModel { JobId = jobId, EstimatedTimeInHours = job.EstimatedTimeHour, ActualTimeTakenHrPart = job.ActualTimeTakenHour, AssignedTakerId = job.AssignedToId, ReportedBy = job.ReportedBy.ClientOrganization, CreatedOn = job.CreatedOn, JobTitle = job.JobTitle, JobType = job.JobCategory, JobStatus = job.Status, JobDescription = job.JobDescription, ReleaseVersion = job.ReleaseVersion, Comments = job.Comments, LastUpdatedOn = job.UpdatedOn, JobPriority = job.JobPriority, FileNames = files }; ViewBag.Takers = _takerBLL.GetTakers(); return(View(model)); }
public Job UpdateJob(UpdateStakeHolderJobViewModel viewModel) { var currentJob = _jobRepository.GetJobById(viewModel.JobId); currentJob.EstimatedTimeHour = viewModel.EstimatedTimeInHours; if (currentJob.AssignedToId != viewModel.AssignedTakerId) { currentJob.AssignedToId = viewModel.AssignedTakerId; } if (!(currentJob.ReleaseVersion.Equals(viewModel.ReleaseVersion))) { currentJob.ReleaseVersion = viewModel.ReleaseVersion; } currentJob.JobTitle = viewModel.JobTitle; currentJob.JobDescription = viewModel.JobDescription; currentJob.JobCategory = viewModel.JobType; currentJob.JobPriority = viewModel.JobPriority; currentJob.UpdatedOn = DateTime.Now; currentJob.Comments = viewModel.Comments; currentJob.AssignedToId = viewModel.AssignedTakerId; return(_jobRepository.Update(currentJob)); }
public ActionResult EditJobForClient(UpdateStakeHolderJobViewModel viewModel) { if (ModelState.IsValid) { string pathName = string.Format("{0}\\{1}", Session.SessionID, (int)Session[Constants.CurrentUserId]); string actualPathName = string.Format("{0}\\{1}", viewModel.JobId, (int)Session[Constants.CurrentUserId]); string sessionFolderPathName = string.Format("{0}", Session.SessionID); var temporaryJobFolderPath = _fileBLL.GetFolderPath(pathName); if (Directory.Exists(temporaryJobFolderPath)) { //Check whether the directory is empty or not. if ((Directory.GetFiles(temporaryJobFolderPath) != null) && (Directory.GetFiles(temporaryJobFolderPath).Length != 0)) { var actualJobFolderPath = _fileBLL.GetFolderPath(actualPathName); string sourceFileName = string.Empty; string destinationFileName = string.Empty; string[] files = Directory.GetFiles(temporaryJobFolderPath); if (!(Directory.Exists(actualJobFolderPath))) { Directory.CreateDirectory(actualJobFolderPath); } //Physically move files from the session folder foreach (var file in files) { sourceFileName = System.IO.Path.GetFileName(file); destinationFileName = System.IO.Path.Combine(actualJobFolderPath, sourceFileName); System.IO.File.Copy(file, destinationFileName, true); } sessionFolderPathName = _fileBLL.GetFolderPath(sessionFolderPathName); try { files = Directory.GetFiles(sessionFolderPathName, "*.*", SearchOption.AllDirectories) != null?Directory.GetFiles(sessionFolderPathName, "*.*", SearchOption.AllDirectories) : null; Array.ForEach(files, System.IO.File.Delete); var sessionDirectories = Directory.GetDirectories(sessionFolderPathName); foreach (var directory in sessionDirectories) { Directory.Delete(directory); } Directory.Delete(sessionFolderPathName); } catch { } } } var job = _jobBLL.UpdateJob(viewModel); //return RedirectToAction("ViewClientReportedRequests", "ReportRequest"); return(RedirectToAction("EditJobForClient", new { jobId = job.JobId })); } else { ModelState.AddModelError("", "Fill in all the fields"); } return(View(viewModel)); }