예제 #1
0
        public async Task <IActionResult> Put(UpdateRewardDto rewardDto)
        {
            var rewardEntity = SimpleMapper.Map <UpdateRewardDto, RewardEntity>(rewardDto);

            await _rewardService.UpdateAsync(rewardEntity);

            return(Ok());
        }
예제 #2
0
        public async Task <IActionResult> PutAsync(int id, [FromBody] Reward resource)
        {        // if Model is invalid show error message by using ModelState
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            //get data form EmployeeAttendenceResource by id using AutoMapper
            //var reward=_mapper.Map<SaveRewardResource,Reward>(resource);
            //update data by id
            var result = await _rewardService.UpdateAsync(id, resource);

            //if updated data is null
            if (result == null)
            {
                return(BadRequest(result));
            }
            //get result data from SaveEmployeeResource after update data using automapper
            var rewardResource = _mapper.Map <Reward, RewardResource>(result.Reward);

            //show data
            return(Ok(rewardResource));
        }