/// <summary> /// افزودن بارگیر /// </summary> /// <param name="modle"></param> /// <returns></returns> public async Task <PackageTypeDTO> Add(PackageTypeDTO modle) { try { var data = _mapper.Map <PackageType>(modle); _repPackageType.Insert(data); await _uow.SaveChangesAsync(); modle.ID = data.ID; return(modle); } catch (Exception e) { throw new ServiceExeption(e.Message, e); } }
public async Task <IActionResult> Add([FromBody] PackageTypeDTO model) { if (!ModelState.IsValid) { return(new ValidationFailedResult(ModelState)); } try { var data = await _service.Add(model); return(Ok(data)); } catch (Exception e) { ModelState.AddModelError("PopUpError", e.Message); return(new ValidationFailedResult(ModelState)); } }