public async Task <SnooksViewModel> GetSnooksValues(SnooksCalculateDto dto)
        {
            var response = await _httpClient.PostAsJsonAsync <SnooksCalculateDto>(BaseUrl + "/helpers/snooks", dto);

            var viewModel = response.Content.ReadFromJsonAsync <SnooksViewModel>().Result;

            return(viewModel);
        }
Example #2
0
        public SnooksViewModel CalculateSnooks(SnooksCalculateDto dto)
        {
            var vm       = new SnooksViewModel();
            int distance = Math.Abs(dto.ToHeight - dto.FromHeight);

            vm.StrMalePercentage = SnooksPercentage("Male", dto.WeightLb, distance);
            vm.IntMalePercentage = ConvertToNumber(vm.StrMalePercentage);

            vm.StrFemalePercentage = SnooksPercentage("Female", dto.WeightLb, distance);
            vm.IntFemalePercentage = ConvertToNumber(vm.StrFemalePercentage);

            return(vm);
        }
Example #3
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);
        }
 public IActionResult CalculateSnooks(SnooksCalculateDto dto)
 {
     return(Ok(_helperService.CalculateSnooks(dto)));
 }