public async Task <IActionResult> PutBloodWork(int id, BloodWork bloodWork) { if (id != bloodWork.BloodWorkID) { return(BadRequest()); } _context.Entry(bloodWork).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BloodWorkExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <BloodWork> > PostBloodWork(BloodWork bloodWork) { _context.BloodWork.Add(bloodWork); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBloodWork", new { id = bloodWork.BloodWorkID }, bloodWork)); }
public ActionResult Save(BloodWork bloodWork) { if (bloodWork.Id == 0) { bloodWork.DateCreated = DateTime.UtcNow; _context.BloodWork.Add(bloodWork); } else { var bloodWorkInDb = _context.BloodWork.Single(b => b.Id == bloodWork.Id); //Update each field bloodWorkInDb.ExamDate = bloodWork.ExamDate; bloodWorkInDb.ResultDate = bloodWork.ResultDate; bloodWorkInDb.Description = bloodWork.Description; bloodWorkInDb.Hematocrit = bloodWork.Hematocrit; bloodWorkInDb.Hemoglobin = bloodWork.Hemoglobin; bloodWorkInDb.MCV = bloodWork.MCV; bloodWorkInDb.MCHC = bloodWork.MCHC; bloodWorkInDb.RDW = bloodWork.RDW; bloodWorkInDb.WhiteBloodCellCount = bloodWork.WhiteBloodCellCount; bloodWorkInDb.RedBloodCellCount = bloodWork.RedBloodCellCount; bloodWorkInDb.PlateletCount = bloodWork.PlateletCount; } _context.SaveChanges(); return(RedirectToAction("Index", "BloodWork")); }
public async Task <IActionResult> PutBloodWork([FromRoute] int id, [FromBody] BloodWork bloodWork) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bloodWork.IdBloodWorks) { return(BadRequest()); } _context.Entry(bloodWork).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BloodWorkExists(id)) { return(NotFound()); } else { throw; } } return(CreatedAtAction("GetBloodWork", new { id = bloodWork.IdBloodWorks }, bloodWork)); }
public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var user = await _db.Users.SingleOrDefaultAsync(x => x.UserName == _userAccessor.GetCurrentUserName()); var bloodWork = new BloodWork { Id = request.Id, Description = request.Description, DateCreated = request.DateCreated, ExamDate = request.ExamDate, ResultsDate = request.ResultsDate, Hemoglobin = request.Hemoglobin, Hematocrit = request.Hematocrit, WBCellsCount = request.WBCellsCount, RBCellsCount = request.RBCellsCount, AppUserId = user.Id }; _db.BloodWorks.Add(bloodWork); var success = await _db.SaveChangesAsync() > 0; if (success) { return(Unit.Value); } throw new Exception("Problem saving changes"); }
//This is bringing new data in the parameter which is updated in form public async Task <IActionResult> EditPost(BloodWork bloodWork) { //this will assign entire data of ASPNETUSERS Table value to user. This is how we capture ID of patient using this application if they are signed in var user = await _userManager.GetUserAsync(HttpContext.User); //Instantiating method to assign data that came from form to ta database table if (ModelState.IsValid) { var bWork = _context.BloodWork.Where(x => x.BloodWorkID == bloodWork.BloodWorkID).FirstOrDefault(); bWork.DateCreated = bloodWork.DateCreated; bWork.ExamDate = bloodWork.ExamDate; bWork.ResultDate = bloodWork.ResultDate; bWork.Description = bloodWork.Description; bWork.Hemoglobin = bloodWork.Hemoglobin; bWork.Hematocrit = bloodWork.Hematocrit; bWork.WhiteBloodCellCount = bloodWork.WhiteBloodCellCount; bWork.RedBloodCellCount = bloodWork.RedBloodCellCount; bWork.ApplicationUserID = Convert.ToString(user.Id); _context.Update(bWork); _context.SaveChanges(); } //Updates record in existing row and saves changes //The code below will send to Index page which has list of patient's blood work return(RedirectToAction("Index")); }
public async Task <IActionResult> Delete(BloodWork bloodWork) { //this will assign entire data of ASPNETUSERS Table value to user. This is how we capture ID of patient using this application if they are signed in var user = await _userManager.GetUserAsync(HttpContext.User); var BloodWorkAddPatient = _context.BloodWork.Where(x => x.BloodWorkID == bloodWork.BloodWorkID).FirstOrDefault(); _context.BloodWork.Remove(BloodWorkAddPatient); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> PostBloodWork([FromBody] BloodWork bloodWork) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.BloodWork.Add(bloodWork); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBloodWork", new { id = bloodWork.IdBloodWorks }, bloodWork)); }
public ActionResult ConfirmDelete(int id, BloodWork result) { result = _context.BloodWork.Find(id); if (result == null) { return(HttpNotFound()); } _context.BloodWork.Remove(result); _context.SaveChanges(); return(RedirectToAction("Index", "BloodWork")); }
//GET : /Cursos/Delete/ public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BloodWork result = _context.BloodWork.Find(id); if (result == null) { return(HttpNotFound()); } return(View("ConfirmDelete")); }
static void Main(string[] args) { var work = new BloodWork() { drugConc = 0.1, dilution = 0.2, volume = 0.3, vein = new BloodComponents() { name = "A", RBC = 0.2, salt = 0.6 }, artery = new BloodComponents() { name = "B", RBC = 0.5, salt = 0.9 } }; }
public async Task <IActionResult> AddBloodWork(BloodWork bloodwork) { //this will assign entire data of ASPNETUSERS Table value to user. This is how we capture ID of patient using this application if they are signed in var user = await _userManager.GetUserAsync(HttpContext.User); //Instantiating method to assign data that came from form to ta database table BloodWork bWork = new BloodWork(); bWork.DateCreated = bloodwork.DateCreated; bWork.ExamDate = bloodwork.ExamDate; bWork.ResultDate = bloodwork.ResultDate; bWork.Description = bloodwork.Description; bWork.Hemoglobin = bloodwork.Hemoglobin; bWork.Hematocrit = bloodwork.Hematocrit; bWork.WhiteBloodCellCount = bloodwork.WhiteBloodCellCount; bWork.RedBloodCellCount = bloodwork.RedBloodCellCount; bWork.ApplicationUserID = (user.Id); //Adds record in new row and saves changes _context.BloodWork.Add(bWork); _context.SaveChanges(); //The code below will send to Index page which has list of patient's blood work return(RedirectToAction(nameof(Index))); }
public static void Initialize(BloodWorkContext context) { context.Database.EnsureCreated(); if (context.BloodWork.Any()) { return; } //Creates initial data to insert in the Db var bloodWorks = new BloodWork[] { new BloodWork { DateCreated = DateTime.Parse("2017-11-02"), ExamDate = DateTime.Parse("2017-11-02"), ResultsDate = DateTime.Parse("2017-11-15"), Description = "Blood Test 1", Hemoglobin = 14, Hematocrit = 45, WhiteBloodCellCount = 4300, RedBloodCellCount = 5.9, MCV = 90, MCHC = 28, RDW = 11, PlateletCount = 300000 }, new BloodWork { DateCreated = DateTime.Parse("2018-01-13"), ExamDate = DateTime.Parse("2018-01-13"), ResultsDate = DateTime.Parse("2018-01-20"), Description = "Blood Test 2", Hemoglobin = 16, Hematocrit = 48, WhiteBloodCellCount = 10800, RedBloodCellCount = 4.2, MCV = 100, MCHC = 36, RDW = 15, PlateletCount = 150000 }, new BloodWork { DateCreated = DateTime.Parse("2018-04-20"), ExamDate = DateTime.Parse("2018-04-20"), ResultsDate = DateTime.Parse("2018-04-28"), Description = "Blood Test 3", Hemoglobin = 18, Hematocrit = 52, WhiteBloodCellCount = 7800, RedBloodCellCount = 5.0, MCV = 80, MCHC = 32, RDW = 12, PlateletCount = 400000 } }; foreach (BloodWork b in bloodWorks) { context.BloodWork.Add(b); } try { context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.ToString()); } }