コード例 #1
0
        public JobCardViewModel GetJobCard(int Id)
        {
            JobCard jobCard = _unitOfWork.JobCardRepository.GetById(Id);

            if (jobCard == null)
            {
                return(null);
            }
            List <JobPartsViewModel> jobPartsViews = new List <JobPartsViewModel>();

            foreach (JobParts jobPart in jobCard.JobParts)
            {
                JobPartsViewModel jobPartView = new JobPartsViewModel(jobPart)
                {
                    SparePart = new SparePartsViewModel(jobPart.SparePart)
                };
                jobPartsViews.Add(jobPartView);
            }

            EmployeeViewModel employee = new EmployeeViewModel(jobCard.Employee);

            JobCardViewModel jobCardView = new JobCardViewModel(jobCard)
            {
                JobParts = jobPartsViews,
                Employee = employee
            };

            return(jobCardView);
        }
コード例 #2
0
 public IActionResult UpdateJobPart(JobPartsViewModel jobPartPost)
 {
     if (!ModelState.IsValid)
     {
         return(View(jobPartPost));
     }
     _jobPart.UpdateJobPart(jobPartPost);
     return(RedirectToRoute(new { controller = "JobCard", action = "GetJobCard", Id = jobPartPost.JobCardId }));
 }
コード例 #3
0
        public void UpdateJobPart(JobPartsViewModel jobPartPost)
        {
            JobParts jobPart = _unitOfWork.JobPartRepository.GetById(jobPartPost.JobCardId, jobPartPost.SparePartId);

            int addedPart = jobPartPost.QuantityInstalled - jobPart.QuantityInstalled;

            jobPart.SparePart.QuantityInStock = (jobPart.SparePart.QuantityInStock - addedPart);

            jobPart.QuantityInstalled = jobPartPost.QuantityInstalled;

            _unitOfWork.JobPartRepository.Update(jobPart);
            _unitOfWork.Save();
            _logger.LogInfo($"Part Id {jobPart.SparePartId} for job {jobPart.JobCardId} updated");
        }
コード例 #4
0
        public void InsertJobPart(JobPartsViewModel jobPartView)
        {
            JobParts jobPart = new JobParts
            {
                JobCardId         = jobPartView.JobCardId,
                SparePartId       = jobPartView.SparePartId,
                QuantityInstalled = jobPartView.QuantityInstalled,
                SparePart         = _unitOfWork.SparePartsRepository.GetById(jobPartView.SparePartId)
            };

            jobPart.SparePart.QuantityInStock = (jobPart.SparePart.QuantityInStock - jobPart.QuantityInstalled);

            _unitOfWork.JobPartRepository.Insert(jobPart);
            _unitOfWork.Save();
            _logger.LogInfo($"Part Id {jobPart.SparePartId} for job {jobPart.JobCardId} inserted");
        }
コード例 #5
0
        public JobPartsViewModel GetJobPart(int jobId, int partId)
        {
            JobParts jobPart = _unitOfWork.JobPartRepository.GetById(jobId, partId);

            if (jobPart == null)
            {
                return(null);
            }

            JobPartsViewModel jobPartsView = new JobPartsViewModel(jobPart)
            {
                JobCard   = new JobCardViewModel(jobPart.JobCard),
                SparePart = new SparePartsViewModel(jobPart.SparePart)
            };

            return(jobPartsView);
        }
コード例 #6
0
        public JobPartsViewModel InsertJobPartView(int jobId)
        {
            IEnumerable <SparePart>    parts     = _unitOfWork.SparePartsRepository.Get();
            List <SparePartsViewModel> partsView = new List <SparePartsViewModel>();

            foreach (SparePart part in parts)
            {
                SparePartsViewModel partView = new SparePartsViewModel(part);
                partsView.Add(partView);
            }

            JobParts          jobParts     = new JobParts();
            JobPartsViewModel jobPartsView = new JobPartsViewModel()
            {
                JobCardId      = jobId,
                SparePartsList = partsView
            };

            return(jobPartsView);
        }
コード例 #7
0
        public IActionResult UpdateJobPart([FromQuery] int jobId, int partId)
        {
            JobPartsViewModel jobPart = _jobPart.GetJobPart(jobId, partId);

            return(View(jobPart));
        }
コード例 #8
0
        public IActionResult InsertJobPart([FromQuery] int jobId)
        {
            JobPartsViewModel newJobPart = _jobPart.InsertJobPartView(jobId);

            return(View(newJobPart));
        }
コード例 #9
0
        public IActionResult GetJobPart(int jobId, int partId)
        {
            JobPartsViewModel jobPartsView = _jobPart.GetJobPart(jobId, partId);

            return(View(jobPartsView));
        }