public async Task <IEnumerable <dynamic> > SaveOrUpdate(ClientDocViewModel cdvm) { string sql = "dbo.EAppSaveClientDocAttachments"; using (var conn = util.MasterCon()) { try { return(await(conn.QueryAsync <dynamic>(sql, new { cdvm.ClientDocAttachId, cdvm.ClientSiteId, cdvm.FileName, cdvm.FileDescription, cdvm.LogicalName, cdvm.PhysicalPath, cdvm.Active, cdvm.UserId }, commandType: CommandType.StoredProcedure))); } catch (Exception ex) { throw new CustomException("Unable to Load Data, 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 FileDescription = ""; if (customHeaders.ContainsKey("aId") && customHeaders.ContainsKey("Type")) { customHeaders.TryGetValue("aId", out aId); customHeaders.TryGetValue("Type", out Type); customHeaders.TryGetValue("fileDescription", out FileDescription); List <FileUploadViewModel> fuvms = await fileUploadService.UploadFiles(Request, HttpContext); foreach (FileUploadViewModel fuvm in fuvms) { ClientDocViewModel cdvm = new ClientDocViewModel(); cdvm.ClientDocAttachId = 0; cdvm.ClientSiteId = Int32.Parse(aId); cdvm.FileDescription = FileDescription; cdvm.FileName = fuvm.OriginalFileName; cdvm.LogicalName = fuvm.LogicalFileName; cdvm.PhysicalPath = fuvm.PhysicalFilePath.Replace(@"\", @"/"); cdvm.Active = "Y"; cdvm.UserId = cUser.UserId; await clientDocRepo.SaveOrUpdate(cdvm); } } await auditLogService.LogActivity(cUser.UserId, cUser.HostIP, cUser.SessionId, "ClientDoc", "Client Document Uploaded"); 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))); } }