public async Task <IActionResult> Create([FromBody] AssetSensorMappingViewModel Asmvm) { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); Asmvm.UserId = cUser.UserId; return(Ok(await AssetSensorMappingRepo.SaveOrUpdate(Asmvm))); } 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))); } }
public async Task <IEnumerable <dynamic> > SaveOrUpdate(AssetSensorMappingViewModel Asmvm) { string sql = "dbo.EAppSaveAssetSensorMapping"; using (var conn = util.MasterCon()) { try { var ShaftJson = JsonHeader + JsonConvert.SerializeObject(Asmvm.Shaft) + JsonFooter; return(await(conn.QueryAsync <dynamic>(sql, new { Asmvm.ClientSiteId, Asmvm.PlantAreaId, Asmvm.EquipmentId, Asmvm.UnitType, Asmvm.UnitID, ShaftJson, Asmvm.UserId }, commandType: CommandType.StoredProcedure))); } catch (SqlException sqlException) { try { CustomUtils.HandleException(sqlException); return(null); // Returned Just to solve compile issue. } catch (CustomException cex) { throw new CustomException(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString()); } } catch (Exception ex) { throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex); } } }