Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initital construct #18

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions MetaPAL/Controllers/ExperimentsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MetaPAL.Controllers
{
public class ExperimentsController : Controller
{
// GET: Experiments
public ActionResult Index()
{
return View();
}

// GET: Experiments/Details/5
public ActionResult Details(int id)
{
return View();
}

// GET: Experiments/Create
public ActionResult Create()
{
return View();
}

// POST: Experiments/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}

// GET: Experiments/Edit/5
public ActionResult Edit(int id)
{
return View();
}

// POST: Experiments/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}

// GET: Experiments/Delete/5
public ActionResult Delete(int id)
{
return View();
}

// POST: Experiments/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
}
}
167 changes: 167 additions & 0 deletions MetaPAL/Controllers/ReposController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
using MetaPAL.Data;
using MetaPAL.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;

namespace MetaPAL.Controllers
{
public class ReposController : Controller
{
private readonly ApplicationDbContext _context;

public ReposController(ApplicationDbContext context)
{
_context = context;
}

// GET: ReposController
public async Task<IActionResult> Index()
{
List<SelectListItem> selectListItems = new List<SelectListItem>()
{
new SelectListItem("Title", "Title"),
new SelectListItem("Description", "Description"),
new SelectListItem("HostingRepositoryURL", "HostingRepositoryURL"),
new SelectListItem("DatasetFtpLocation", "DatasetFtpLocation"),
};

ViewBag.RepoFeatures = selectListItems;
if (_context.Repos == null)
return Problem("Entity set 'ApplicationDbContext.Repos' is null.");
return View(await _context.Repos.ToListAsync());
}

// GET: ReposController/Details/5
public ActionResult Details(int id)
{
return View();
}

// GET: Repos/Create
public IActionResult Create()
{
List<SelectListItem> selectListItems = new List<SelectListItem>()
{
new SelectListItem("Select Repo Features", ""),
new SelectListItem("Title", "Title"),
new SelectListItem("Description", "Description"),
new SelectListItem("HostingRepositoryURL", "HostingRepositoryURL"),
new SelectListItem("DatasetFtpLocation", "DatasetFtpLocation"),
};

ViewBag.RepoFeatures = selectListItems;
return View();
}

// POST: Repo/Create
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
//[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Title,Description,HostingRepositoryURL,DatasetFtpLocation")] Repo repo)
{
if (ModelState.IsValid)
{
_context.Add(repo);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(repo);
}

// GET: Repo/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null || _context.Repos == null)
{
return NotFound();
}

var repo = await _context.Repos.FindAsync(id);
if (repo == null)
{
return NotFound();
}
return View(repo);
}

// POST: Repos/Edit/5
// To protect from overposting attacks, enable the specific properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
//[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Title,Description,HostingRepositoryURL,DatasetFtpLocation")] Repo repo)
{
if (id != repo.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
_context.Update(repo);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!RepoExists(repo.Id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(repo);
}

// GET: Repos/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null || _context.Repos == null)
{
return NotFound();
}

var repo = await _context.Repos
.FirstOrDefaultAsync(m => m.Id == id);
if (repo == null)
{
return NotFound();
}

return View(repo);
}

// POST: Repos/Delete/5
[HttpPost, ActionName("Delete")]
//[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
if (_context.Repos == null)
{
return Problem("Entity set 'ApplicationDbContext.Repo' is null.");
}
var repo = await _context.Repos.FindAsync(id);
if (repo != null)
{
_context.Repos.Remove(repo);
}

await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}

private bool RepoExists(int id)
{
return (_context.Repos?.Any(e => e.Id == id)).GetValueOrDefault();
}
}
}
83 changes: 83 additions & 0 deletions MetaPAL/Controllers/SampleMetaDataController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MetaPAL.Controllers
{
public class SampleMetaDataController : Controller
{
// GET: SampleMetaDataController
public ActionResult Index()
{
return View();
}

// GET: SampleMetaDataController/Details/5
public ActionResult Details(int id)
{
return View();
}

// GET: SampleMetaDataController/Create
public ActionResult Create()
{
return View();
}

// POST: SampleMetaDataController/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}

// GET: SampleMetaDataController/Edit/5
public ActionResult Edit(int id)
{
return View();
}

// POST: SampleMetaDataController/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}

// GET: SampleMetaDataController/Delete/5
public ActionResult Delete(int id)
{
return View();
}

// POST: SampleMetaDataController/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
{
try
{
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
}
}
21 changes: 17 additions & 4 deletions MetaPAL/Controllers/SpectrumMatchesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@
// GET: SpectrumMatches
public async Task<IActionResult> Index()
{
// TEMPORARY: remove all spectrum matches from database
//Task.Run(() => DataOperations.DataOperations.RemoveAll<SpectrumMatch>(_context)).Wait();

List<SelectListItem> selectListItems = new List<SelectListItem>()
{
new SelectListItem("Select Spectrum Match Features", ""),
new SelectListItem("Base Sequence", "BaseSequence"),
new SelectListItem("Full Sequence", "FullSequence"),
new SelectListItem("Accession", "Accession"),
};

ViewBag.SpectrumMatchFeatures = selectListItems;
if (_context.SpectrumMatch == null)
return Problem("Entity set 'ApplicationDbContext.SpectrumMatch' is null.");
return View(await _context.SpectrumMatch.ToListAsync());
}

// GET: UploadSpectralMatchesForm
public async Task<IActionResult> UploadSpectralMatchesForm()

Check warning on line 43 in MetaPAL/Controllers/SpectrumMatchesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
return _context.SpectrumMatch != null ?
View() :
Expand Down Expand Up @@ -67,7 +72,7 @@


// GET: ShowSearchForm
public async Task<IActionResult> ShowSearchForm()

Check warning on line 75 in MetaPAL/Controllers/SpectrumMatchesController.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
return _context.SpectrumMatch != null ?
View() :
Expand Down Expand Up @@ -100,9 +105,17 @@
}

// GET: SpectrumMatches/Create
[Authorize]
public IActionResult Create()
{
List<SelectListItem> selectListItems = new List<SelectListItem>()
{
new SelectListItem("Select Spectrum Match Features", ""),
new SelectListItem("Base Sequence", "BaseSequence"),
new SelectListItem("Full Sequence", "FullSequence"),
new SelectListItem("Accession", "Accession"),
};

ViewBag.SpectrumMatchFeatures = selectListItems;
return View();
}

Expand Down
8 changes: 3 additions & 5 deletions MetaPAL/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Omics.Fragmentation;
using Proteomics;

namespace MetaPAL.Data
{
Expand All @@ -18,14 +19,11 @@ protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}

public DbSet<Repo>? Repos { get; set; }
public DbSet<SpectrumMatch>? SpectrumMatch { get; set; }

public DbSet<MsDataScanModel> MsDataScans { get; set; }

public DbSet<DataFile> MsDataFiles { get; set; }
public DbSet<Experiment> Experiments { get; set; }
public DbSet<MetaData> MetaData { get; set; }
public DbSet<SampleMetaData> MetaData { get; set; }
}


Expand Down
Loading
Loading