Esempio n. 1
0
        public bool Update(UpdateJobTaskDto dto)
        {
            var dbJobTask = _context.JobTasks.Find(dto.Id);

            //
            //make sure this task name is unique for this
            //jobTask
            //
            bool exists = (from item in _context.JobTasks
                           where item.Id != dbJobTask.Id &&
                           item.Name == dto.Name &&
                           item.JobId == dbJobTask.JobId
                           select item).Any();

            if (exists)
            {
                throw new OccumetricException("This task name is already taken in this job description.");
            }

            //
            //calculate niosh and snooks
            //
            var snooksDto = new SnooksCalculateDto
            {
                EffortType = dto.EffortType,
                WeightLb   = (int)dto.WeightLb,
                FromHeight = Utility.SanitizeStringToInteger(dto.FromHeight),
                ToHeight   = Utility.SanitizeStringToInteger(dto.ToHeight),
            };
            var snooksVm = _helperService.CalculateSnooks(snooksDto);

            dbJobTask.SnooksMale   = snooksVm.StrMalePercentage;
            dbJobTask.SnooksFemale = snooksVm.StrFemalePercentage;

            var nioshDto = new NioshCalculateDto
            {
                WeightLb          = (int)dto.WeightLb,
                EffortType        = dto.EffortType,
                FromHeight        = Utility.SanitizeStringToInteger(dto.FromHeight),
                ToHeight          = Utility.SanitizeStringToInteger(dto.ToHeight),
                LiftDurationType  = dto.LiftDurationType,
                LiftFrequencyType = dto.LiftFrequencyType
            };

            dbJobTask.LiftingIndex = _helperService.GetNioshIndex(nioshDto);
            _mapper.Map <UpdateJobTaskDto, JobTask>(dto, dbJobTask);
            _context.SaveChanges();
            return(true);
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateJobTask(UpdateJobTaskDto dto)
        {
            await Task.Run(() => _jobTaskService.Update(dto));

            return(Ok());
        }