public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] TechUpgradeViewModel svm) { string sql = "dbo.EAppSaveTechUpgrade"; using (var conn = util.MasterCon()) { try { return(await(conn.QueryAsync <dynamic>(sql, new { svm.TechUpgradeId, svm.ClientSiteId, svm.EquipmentId, svm.ReportDate, svm.RecommendationDate, svm.Saving, svm.Recommendation, svm.Remarks, svm.OriginalFileName, svm.LogicalFileName, svm.PhysicalFilePath, svm.Active, svm.UserId }, commandType: CommandType.StoredProcedure))); } catch (Exception ex) { throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex); } } }
public async Task <IActionResult> UploadFiles() { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); var customHeaders = Request.Headers; StringValues aId = ""; StringValues Type = ""; StringValues EquipmentId = ""; StringValues PlantAreaId = ""; StringValues Saving = ""; StringValues ReportDate = ""; StringValues RecommendationDate = ""; StringValues Recommendation = ""; StringValues Remarks = ""; if (customHeaders.ContainsKey("aId") && customHeaders.ContainsKey("Type")) { customHeaders.TryGetValue("aId", out aId); customHeaders.TryGetValue("Type", out Type); customHeaders.TryGetValue("equipmentId", out EquipmentId); customHeaders.TryGetValue("plantAreaId", out PlantAreaId); customHeaders.TryGetValue("saving", out Saving); customHeaders.TryGetValue("reportDate", out ReportDate); customHeaders.TryGetValue("recommendationDate", out RecommendationDate); customHeaders.TryGetValue("recommendation", out Recommendation); customHeaders.TryGetValue("remarks", out Remarks); List <FileUploadViewModel> fuvms = await fileUploadService.UploadFiles(Request, HttpContext); foreach (FileUploadViewModel fuvm in fuvms) { TechUpgradeViewModel svm = new TechUpgradeViewModel(); svm.ClientSiteId = Int32.Parse(aId); svm.EquipmentId = Int32.Parse(EquipmentId); svm.ReportDate = DateTime.Parse(ReportDate); svm.Saving = Decimal.Parse(Saving); svm.RecommendationDate = DateTime.Parse(RecommendationDate); svm.Recommendation = Recommendation; svm.OriginalFileName = fuvm.OriginalFileName; svm.LogicalFileName = fuvm.LogicalFileName; svm.PhysicalFilePath = fuvm.PhysicalFilePath.Replace(@"\", @"/"); svm.Active = "Y"; svm.UserId = cUser.UserId; await iRepo.SaveOrUpdate(svm); } } return(Json("Success")); } catch (CustomException cex) { var responseObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError, responseObj)); } catch (Exception ex) { return(Ok(new EmaintenanceMessage(ex.Message))); } }