public async Task <IEnumerable <dynamic> > SaveExportLeverageFiles(LeverageExportViewModel lvm) { string sql = "dbo.EAppSaveLeverageServiceExport"; using (var conn = util.MasterCon()) { try { string LeverageServiceJson = null; if (lvm.LeverageExportServices != null && lvm.LeverageExportServices.Count > 0) { string Header = "{\"LeverageService\": "; string Footer = "}"; LeverageServiceJson = Header + JsonConvert.SerializeObject(lvm.LeverageExportServices) + Footer; } return(await(conn.QueryAsync <dynamic>(sql, new { LeverageServiceJson, lvm.FilePath, lvm.UserId }, commandType: CommandType.StoredProcedure))); } catch (Exception ex) { throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex); } } }
public async Task <IEnumerable <dynamic> > SaveOrUpdate(LeverageExportViewModel lvm) { string sql = "dbo.EAppSaveLeverageService"; using (var conn = util.MasterCon()) { try { return(await(conn.QueryAsync <dynamic>(sql, new { lvm.LeverageServiceId, lvm.JobEquipmentId, lvm.OpportunityTypeId, lvm.Descriptions, lvm.LeverageExportId, lvm.Active, lvm.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> ExportLeverage([FromBody] LeverageExportViewModel lvm) { try { CurrentUser cUser = new CurrentUser(HttpContext, _configuration); lvm.UserId = cUser.UserId; var appConfig = await appConfigRepo.GetAppConfigByName("LeverageFilePath", "Y"); lvm.FilePath = appConfig.AppConfigValue; return(Ok(await leverageExportRepo.SaveExportLeverageFiles(lvm))); } 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))); } }