public async Task <IActionResult> PostPredictionObj([FromBody] ScrewCompressorPredictionModel predictionDetails) { string userId = User.Claims.First(c => c.Type == "UserID").Value; try { DateTime datetime = predictionDetails.InsertedDate; if (datetime == DateTime.MinValue) { predictionDetails.InsertedDate = DateTime.Now; } DateTime dt = predictionDetails.InsertedDate; DateTime dateOnly = dt.Date; predictionDetails.InsertedDate = dateOnly; predictionDetails.TenantId = 1; predictionDetails.UserId = userId; predictionDetails.Prediction = "pending"; _context.ScrewCompressurePredictionData.Add(predictionDetails); await _context.SaveChangesAsync(); return(Ok(predictionDetails)); } catch (Exception exe) { return(BadRequest(exe.Message)); } }
public async Task <IActionResult> GetPredictionById(int PredictedId) { try { ScrewCompressorPredictionModel screwCompressorPredictions = await _context.ScrewCompressurePredictionData.FirstOrDefaultAsync(a => a.PredictionId == PredictedId); return(Ok(screwCompressorPredictions)); } catch (Exception exe) { return(BadRequest(exe.Message)); } }