public async Task <IActionResult> SaveContractTerm([FromBody] ContractTermViewModel contractTermViewModel) { if (contractTermViewModel == null) { return(this.BadRequest(contractTermViewModel)); } var result = await _icontractsStatic.SaveContractTerm(contractTermViewModel).ConfigureAwait(false); if (result < 0) { return(StatusCode(500, result)); } else if (result == 0) { return(this.NoContent()); } return(this.Ok(result)); }
/// <summary> /// SaveContractTerm /// </summary> /// <param name="contractTerm"></param> /// <returns>Task<long></returns> public async Task <long> SaveContractTerm(ContractTermViewModel contractTerm) { var model = AutoMapper.Mapper.Map <ContractTerm>(contractTerm); var result = new BaseResult <long>(); if (contractTerm.ObjectState == ObjectState.Added) { result = await iContractTermLibrary.InsertEntity(model).ConfigureAwait(false); return(result.Result); } else if (contractTerm.ObjectState == ObjectState.Modified) { var updateResult = await iContractTermLibrary.UpdateEntityByDapper(model).ConfigureAwait(false); if (updateResult.Result) { result.Result = model.Id; return(result.Result); } } return(result.Result); }