public IActionResult EnterPhysicalOrientation(PhysicalOrientation po) { var oriid = context.PhysicalOrientation.Skip(context.PhysicalOrientation.Count() - 1).Take(1).FirstOrDefault().OrientationId; oriid++; po.OrientationId = oriid; //first check data to make sure it's good before passing to Model and DB if (ModelState.IsValid) { NewMummy.burial.OrientationId = po.OrientationId; NewMummy.physicalOrientation = po; //Update Database context.PhysicalOrientation.Add(po); context.SaveChanges(); return(View("EnterFieldBody")); } //Otherwise return(View()); }
public IActionResult EditPhysicalOrientation2(PhysicalOrientation po) { if (ModelState.IsValid) { var ori = context.PhysicalOrientation.SingleOrDefault(x => x.OrientationId == po.OrientationId); context.Entry(ori).Property(x => x.WtoFeet).CurrentValue = po.WtoFeet; context.Entry(ori).Property(x => x.StoFeet).CurrentValue = po.StoFeet; context.Entry(ori).Property(x => x.WtoHead).CurrentValue = po.WtoHead; context.Entry(ori).Property(x => x.StoHead).CurrentValue = po.StoHead; context.Entry(ori).Property(x => x.HeadDirection).CurrentValue = po.HeadDirection; context.Entry(ori).Property(x => x.BurialDepth).CurrentValue = po.BurialDepth; context.Entry(ori).Property(x => x.LengthOfRemainsInMeters).CurrentValue = po.LengthOfRemainsInMeters; context.SaveChanges(); return(RedirectToAction("BurialList")); } else { return(View()); } }
public IActionResult EditPhysicalOrientation(int OrientationId) { PhysicalOrientation po = context.PhysicalOrientation.Single(x => x.OrientationId == OrientationId); return(View(po)); }