public async Task <IActionResult> AddAsync(FirmDTO firmDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }
            else
            {
                _mapper = FirmMapping.GetMapper().CreateMapper();
                //Using with Automapper mapped by Firm to FirmDTO
                Firm firm = _mapper.Map <FirmDTO, Firm>(firmDTO);
                //Firm firm = new Firm();

                //firm.FirmName = firmDTO.FirmName;
                //firm.ParentID = firmDTO.ParentID; //instead of this

                var FirmResult = await _Firmservice.AddAsync(firm);

                if (FirmResult.Success)
                {
                    return(Ok(FirmResult.Message));
                }
                else
                {
                    return(BadRequest(FirmResult.Message));
                }
            }
        }
示例#2
0
 public async Task <IActionResult> Add(FirmDto request)
 {
     return(HandleServiceResponse(await _service.AddAsync(GetClaims(), request)));
 }