public async Task <IActionResult> DrivenUpdate([FromBody] DrivenUnitViewModel dvm) { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); dvm.UserId = cUser.UserId; return(Ok(await equipmentRepo.SaveOrUpdate(dvm))); } 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([FromBody] DrivenUnitViewModel dvm) { string sql = "dbo.EAppSaveEquipmentDrivenUnit"; using (var conn = util.MasterCon()) { try { var ReportServicesJson = JsonHeader + JsonConvert.SerializeObject(dvm.ReportingServices) + JsonFooter; //var DEBearingJson = JsonHeader + JsonConvert.SerializeObject(dvm.BearingDriveEnd) + JsonFooter; //var NDEBearingJson = JsonHeader + JsonConvert.SerializeObject(dvm.BearingNonDriveEnd) + JsonFooter; var ShaftJson = JsonHeader + JsonConvert.SerializeObject(dvm.Shaft) + JsonFooter; return(await(conn.QueryAsync <dynamic>(sql, new { dvm.DrivenUnitId, dvm.EquipmentId, dvm.AssetId, dvm.IdentificationName, dvm.ListOrder, dvm.ManufacturerId, dvm.MaxRPM, dvm.Capacity, dvm.Model, dvm.Lubrication, dvm.SerialNumber, dvm.RatedFlowGPM, dvm.PumpEfficiency, dvm.RatedSuctionPressure, dvm.Efficiency, dvm.RatedDischargePressure, dvm.CostPerUnit, //dvm.BearingDriveEndId, //dvm.BearingNonDriveEndId, dvm.ImpellerVanes, dvm.ImpellerVanesKW, dvm.Stages, dvm.NumberOfPistons, dvm.PumpType, dvm.MeanRepairManHours, dvm.DownTimeCostPerHour, dvm.CostToRepair, dvm.MeanFailureRate, ReportServicesJson, ShaftJson, dvm.Active, dvm.UserId, dvm.ManufactureYear, dvm.FirstInstallationDate, dvm.OperationModeId, dvm.SensorProviderId }, 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); } } }