コード例 #1
0
        public async Task <IActionResult> UpdateAsync(FirmDTO firmDTO, int Id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                IDataResult <Firm> firmDataResult = await _Firmservice.FindByIdAsync(Id);

                if (firmDataResult.Data == null)
                {
                    return(BadRequest(firmDataResult.Message));
                }
                _mapper = FirmMapping.GetMapper().CreateMapper();
                Firm firm = _mapper.Map <FirmDTO, Firm>(firmDTO);
                firm.ID = firmDataResult.Data.ID;
                IResult firmResult = await _Firmservice.UpdateAsync(firm);

                if (firmResult.Success)
                {
                    return(Ok(firmResult.Message));
                }
                else
                {
                    return(BadRequest(firmResult.Message));
                }
            }
        }
コード例 #2
0
 public async Task <IActionResult> Update(FirmDto request)
 {
     return(HandleServiceResponse(await _service.UpdateAsync(GetClaims(), request)));
 }