public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } fileuploadVM.file = files.FirstOrDefault(); fileuploadVM.FileName = files.FirstOrDefault().FileName; fileuploadVM.fileSize = files.FirstOrDefault().Length; fileuploadVM.Type = fileuploadVM.Type; fileuploadVM.save(); _context.Attach(fileuploadVM).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FileUploadExists(fileuploadVM.id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./FileUploadIndex")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(FirebaseSetting).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FirebaseSettingExists(FirebaseSetting.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./firebaseIndex")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var webpath = _env.WebRootPath; var filePath = Path.Combine(webpath, "images/" + firebasesettingvm.file.FileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { await firebasesettingvm.file.CopyToAsync(fileStream); } //var fileData = await FileHelpers.ProcessFormFile(firebasesettingvm.file, ModelState); //firebasesettingvm.GoogleServicesData = fileData; // firebasesettingvm.GoogleServicesSize = firebasesettingvm.file.Length; FirebaseSetting model = new FirebaseSetting(); _mapper.Map(firebasesettingvm, model); _context.FirebaseSettings.Add(model); await _context.SaveChangesAsync(); return(RedirectToPage("./firebaseIndex")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } FirebaseSetting = await _context.FirebaseSettings.FindAsync(id); if (FirebaseSetting != null) { _context.FirebaseSettings.Remove(FirebaseSetting); await _context.SaveChangesAsync(); } return(RedirectToPage("./firebaseIndex")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } FileUpload = await _context.FileUploads.FindAsync(id); if (FileUpload != null) { _context.FileUploads.Remove(FileUpload); await _context.SaveChangesAsync(); } return(RedirectToPage("./FileUploadIndex")); }