public async Task <IActionResult> IntermediateUpdate([FromBody] IntermediateUnitViewModel ivm) { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); ivm.UserId = cUser.UserId; return(Ok(await equipmentRepo.SaveOrUpdate(ivm))); } 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] IntermediateUnitViewModel ivm) { string sql = "dbo.EAppSaveEquipmentIntermediateUnit"; using (var conn = util.MasterCon()) { try { var ReportServicesJson = JsonHeader + JsonConvert.SerializeObject(ivm.ReportingServices) + JsonFooter; var DEBearingJson = JsonHeader + JsonConvert.SerializeObject(ivm.BearingDriveEnd) + JsonFooter; var NDEBearingJson = JsonHeader + JsonConvert.SerializeObject(ivm.BearingNonDriveEnd) + JsonFooter; var ShaftJson = JsonHeader + JsonConvert.SerializeObject(ivm.Shaft) + JsonFooter; return(await(conn.QueryAsync <dynamic>(sql, new { ivm.IntermediateUnitId, ivm.EquipmentId, ivm.AssetId, ivm.IdentificationName, ivm.ListOrder, ivm.ManufacturerId, ivm.Ratio, ivm.Size, ivm.Model, ivm.BeltLength, ivm.PulleyDiaDrive, ivm.PulleyDiaDriven, ivm.RatedRPMInput, ivm.RatedRPMOutput, ivm.PinionInputGearTeeth, ivm.PinionOutputGearTeeth, ivm.IdlerInputGearTeeth, ivm.IdlerOutputGearTeeth, ivm.BullGearTeeth, ivm.Serial, //ivm.BearingInputId, //ivm.BearingOutputId, ivm.MeanRepairManHours, ivm.DownTimeCostPerHour, ivm.CostToRepair, ivm.MeanFailureRate, ReportServicesJson, ShaftJson, ivm.Active, ivm.UserId, ivm.ManufactureYear, ivm.FirstInstallationDate, ivm.OperationModeId, ivm.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); } } }