public ActionResult AddDonation(int id) { AddDonateViewModel model = new AddDonateViewModel() { AppointmentId = id, Quantity = 0, Date = DateTime.Today, Plasma = 0, Thrombocytes = 0, RedCell = 0, BloodType = -1 }; return(View(model)); }
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)); }