public IActionResult CustomCreate(FieldBook fieldNote) { if (ModelState.IsValid) { _context.Add(fieldNote); _context.SaveChanges(); return(View("RecordDetails", new FieldNotesViewModel { fieldNotes = _context.FieldBook.Where(x => x.BurialId == fieldNote.BurialId), burial = _context.Burials.Where(x => x.BurialId == fieldNote.BurialId).FirstOrDefault(), fieldNote = fieldNote })); } return(View(fieldNote)); }
// Create new carbon dating -- create is keyword with strange functions public IActionResult CustomCreate(C14 carbDateSample) { if (ModelState.IsValid) { _context.Add(carbDateSample); _context.SaveChanges(); return(View("RecordDetails", new CarbonDatingViewModel { carbDateSamples = _context.C14s.Where(x => x.BurialId == carbDateSample.BurialId), burial = _context.Burials.Where(x => x.BurialId == carbDateSample.BurialId).FirstOrDefault(), carbDateSample = carbDateSample })); } return(View(carbDateSample)); }
public IActionResult CustomCreate([Bind("BurialId,Rack,F3,Bag,LowNs,HighNs,NorthOrSouth,LowEw,HighEw,EastOrWest,Area,BurialNumber,ClusterNumber,Date,PreviouslySampled,Notes,Initials,Id")] BiologicalSample bio) { if (ModelState.IsValid) { _context.Add(bio); _context.SaveChanges(); return(View("RecordSpecificIndex", new BioSampleViewModel { biologicalSamples = _context.BiologicalSamples.Where(x => x.BurialId == bio.BurialId), burial = _context.Burials.Where(x => x.BurialId == bio.BurialId).FirstOrDefault(), bioSample = bio })); } ViewData["BurialId"] = new SelectList(_context.Burials, "BurialId", "BurialId", bio.BurialId); return(View(bio)); }
public IActionResult CustomCreate(Cranial cranialSample) { if (_context.Cranials.Where(x => x.BurialId == cranialSample.BurialId).FirstOrDefault() != null) { return(View("No")); } if (ModelState.IsValid) { _context.Add(cranialSample); _context.SaveChanges(); return(View("RecordDetails", new CranialViewModel { cranialSamples = _context.Cranials.Where(x => x.BurialId == cranialSample.BurialId), burial = _context.Burials.Where(x => x.BurialId == cranialSample.BurialId).FirstOrDefault(), cranialSample = cranialSample })); } return(View(cranialSample)); }
public IActionResult AddBurial(BurialViewModel b, int LocationId, DateTime date) { b.Burial.LocationId = LocationId; b.Burial.DayFound = date.ToString("dd"); b.Burial.MonthFound = date.ToString("MM"); b.Burial.YearFound = date.ToString("yyyy"); context.Burial.Add(b.Burial); //Location l = context.Location.Single(l => l.LocationId == LocationId); foreach (Burial burial in context.Burial.Where(b => b.LocationId == LocationId)) { if (burial.BurialNumber == b.Burial.BurialNumber) { //return Burial already stored. return(View("ErrorBurial")); } } context.SaveChanges(); Burial lastBurial = context.Burial.OrderByDescending(b => b.BurialId).First(); return(RedirectToAction("SingleBurial", new { BurialId = lastBurial.BurialId })); }