public ActionResult Create(DonationMvc donati, HttpPostedFileBase image) { if (!ModelState.IsValid || image == null || image.ContentLength == 0) { RedirectToAction("Create"); } donation don = new donation(); don.lieuDonation = donati.lieuDonation; don.TitreDonation = donati.TitreDonation; don.TypeDonation = donati.TypeDonation; don.image = image.FileName; don.id = donati.id; don.dateajout = donati.dateajout; don.disponibilite = donati.disponibilite; don.email = donati.email; sc.Add(don); sc.Commit(); var path = Path.Combine(Server.MapPath("~/Content/Upload/"), image.FileName); image.SaveAs(path); return(RedirectToAction("Index")); }
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)); }