public async Task <IEnumerable <dynamic> > SaveOrUpdate(AssetMappingViewModel amvm) { string sql = "dbo.EAppSaveAssetObserverMapping"; using (var conn = util.MasterCon()) { try { return(await(conn.QueryAsync <dynamic>(sql, new { amvm.AssetType, amvm.AssetId, amvm.ObserverNodeId, amvm.ObserverNodeName, amvm.ObserverNodePath }, commandType: CommandType.StoredProcedure))); } catch (SqlException sqlException) { throw new CustomException("Due to some Technical Reason, Unable to Save or Update", "Error", true, sqlException); } catch (Exception ex) { throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex); } } }
public async Task <IActionResult> Create([FromBody] AssetMappingViewModel amvm) { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); return(Ok(await AssetMappingRepo.SaveOrUpdate(amvm))); } catch (CustomException cex) { var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError, returnObj)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message))); } }