コード例 #1
0
 public async Task <IActionResult> DriveUpdate([FromBody] DriveUnitViewModel 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)));
     }
 }
コード例 #2
0
        public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] DriveUnitViewModel duvm)
        {
            string sql = "dbo.EAppSaveEquipmentDriveUnit";

            using (var conn = util.MasterCon())
            {
                try
                {
                    var ReportServicesJson = JsonHeader + JsonConvert.SerializeObject(duvm.ReportingServices) + JsonFooter;
                    //var DEBearingJson = JsonHeader + JsonConvert.SerializeObject(duvm.BearingDriveEnd) + JsonFooter;
                    //var NDEBearingJson = JsonHeader + JsonConvert.SerializeObject(duvm.BearingNonDriveEnd) + JsonFooter;
                    var ShaftJson = JsonHeader + JsonConvert.SerializeObject(duvm.Shaft) + JsonFooter;

                    return(await(conn.QueryAsync <dynamic>(sql, new
                    {
                        duvm.DriveUnitId,
                        duvm.EquipmentId,
                        duvm.AssetId,
                        duvm.IdentificationName,
                        duvm.ListOrder,
                        duvm.ManufacturerId,
                        duvm.RPM,
                        duvm.Frame,
                        duvm.Voltage,
                        duvm.PowerFactor,
                        duvm.UnitRate,
                        duvm.Model,
                        duvm.HP,
                        duvm.Type,
                        duvm.MotorFanBlades,
                        duvm.SerialNumber,
                        duvm.RotorBars,
                        duvm.Poles,
                        duvm.Slots,
                        //duvm.BearingDriveEndId,
                        //duvm.BearingNonDriveEndId,
                        duvm.PulleyDiaDrive,
                        duvm.PulleyDiaDriven,
                        duvm.BeltLength,
                        duvm.CouplingId,
                        duvm.MeanRepairManHours,
                        duvm.DownTimeCostPerHour,
                        duvm.CostToRepair,
                        duvm.MeanFailureRate,
                        ReportServicesJson,
                        ShaftJson,
                        duvm.Active,
                        duvm.UserId,
                        duvm.ManufactureYear,
                        duvm.FirstInstallationDate,
                        duvm.OperationModeId,
                        duvm.LineFrequencyId,
                        duvm.SpeedTypeId,
                        duvm.SensorProviderId,
                        duvm.MinRPM,
                        duvm.MaxRPM
                    }, 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);
                }
            }
        }