public async Task <IFileResponse> UploadDocumentsAsync(UploadAllDocumentView model) { try { var allResponse = new List <FileView>(); var profile = await _appDbContext.Profiles.FirstOrDefaultAsync(k => k.Id == model.UserId); if (profile == null) { return(new FileResponse(ClientMessageConstant.ProfileNotExist, HttpStatusCode.NotFound)); } if (model.PassportFile != null) { profile.PassportFileId = await FileUploadAsync(model.PassportFile, profile, allResponse, DocumentType.Passport); } if (model.CVFile != null) { profile.CvfileId = await FileUploadAsync(model.CVFile, profile, allResponse, DocumentType.CV); } if (model.EducationFile != null) { profile.LastEducationCertificateFileId = await FileUploadAsync(model.EducationFile, profile, allResponse, DocumentType.Education); } if (model.EmiratesFile != null) { profile.UaeidfileId = await FileUploadAsync(model.EmiratesFile, profile, allResponse, DocumentType.Emirates); } if (model.FamilyBookFile != null) { profile.FamilyBookFileId = await FileUploadAsync(model.FamilyBookFile, profile, allResponse, DocumentType.FamilyBook); } await _appDbContext.SaveChangesAsync(); return(new FileResponse(allResponse)); } catch (Exception e) { return(new FileResponse(e)); } }
public async Task <IActionResult> UploadDocumentsAsync([FromForm] UploadAllDocumentView viewModel) { var model = await _fileService.UploadDocumentsAsync(viewModel); return(Ok(model)); }