private bool IsValid(Thrombocytes Entity) { if (Entity.UsedDate > Entity.ExpirationDate || Entity.Quantity < 0) { return(false); } return(true); }
public Thrombocytes Add(DateTime ExpirationDate, DateTime?UsedDate, int Quantity) { Thrombocytes p = new Thrombocytes() { ExpirationDate = ExpirationDate, UsedDate = UsedDate, Quantity = Quantity }; Repository.Add(p); return(p); }
public void Add(Thrombocytes Entity) { if (IsValid(Entity)) { using (var context = new DatabaseContainer()) { context.ThrombocytesSet.Add(Entity); try { context.SaveChanges(); } catch (Exception) { throw new ArgumentException("There is already a Thrombocyte result with that id"); } } } }
public ActionResult DonationComplete(AddDonateViewModel model) { if (!ModelState.IsValid) { return(View("AddDonation", model)); } if (model.Plasma < 0 || model.RedCell < 0 || model.Thrombocytes < 0) { ModelState.AddModelError(String.Empty, "Quantity cannot be 0"); return(View("AddDonation", model)); } else if (model.Date < DateTime.Today) { ModelState.AddModelError(String.Empty, "Date cannot be before today"); return(View("AddDonation", model)); } else { DonationAppointment app = _donationAppointmentService.GetById(model.AppointmentId); _donationAppointmentService.Update(app.Id, app.AppointmentDate, app.RequestId, true, app.ProfileId, app.TransfusionCenterId); Plasma p = _plasmaService.Add(model.Date.AddMonths(2), null, model.Plasma); RedCell r = _redCellService.Add(model.Date.AddDays(42), null, model.RedCell); Thrombocytes t = _thrombocytesService.Add(model.Date.AddDays(5), null, model.Thrombocytes); BloodSeparation b = _bloodSeparation.Add(p.Id, r.Id, t.Id); Donation d = _donationService.Add(app.RequestId, model.Plasma + model.RedCell + model.Thrombocytes, model.Date, false, StatusEnum.Preparated, app.ProfileId, b.Id, model.BloodType); LabResult lb = _labResultService.Add(false, false, false, false, false, "None", d.Id); } return(View("AddDonation", model)); }