public void Update(UpdateMasterTaskDto dto) { var IntFromHeight = Utility.SanitizeStringToInteger(dto.FromHeight); var IntToHeight = Utility.SanitizeStringToInteger(dto.ToHeight); var snooksValues = _helperService.CalculateSnooks(new SnooksCalculateDto { EffortType = dto.EffortType, FromHeight = IntFromHeight, ToHeight = IntToHeight, WeightLb = (int)dto.WeightLb }); var nioshIndex = _helperService.GetNioshIndex(new NioshCalculateDto { EffortType = dto.EffortType, FromHeight = IntFromHeight, ToHeight = IntToHeight, WeightLb = (int)dto.WeightLb }); var dbMasterTask = _context.MasterTasks.Find(dto.Id); dbMasterTask = _mapper.Map <UpdateMasterTaskDto, MasterTask>(dto, dbMasterTask); dbMasterTask.LiftingIndex = nioshIndex; dbMasterTask.SnooksMale = snooksValues.StrMalePercentage; dbMasterTask.SnooksFemale = snooksValues.StrFemalePercentage; dbMasterTask.TaskCategoryMaps.Clear(); foreach (var id in dto.TaskCategoryViewModels.Select(x => x.Id).ToList()) { dbMasterTask.TaskCategoryMaps.Add(new TaskCategoryMap { MasterTaskId = dbMasterTask.Id, TaskCategoryId = id }); } _context.SaveChanges(); }
public async Task <IActionResult> Update(UpdateMasterTaskDto dto) { await Task.Run(() => _masterTaskService.Update(dto)); return(Ok()); }