public IActionResult AddDonor(AddDonorViewModel addDonorViewModel) { if (ModelState.IsValid) { Address address = new Address(addDonorViewModel.Line1, addDonorViewModel.Line2, addDonorViewModel.City, addDonorViewModel.State, addDonorViewModel.Zip); Donor newDonor = new Donor { FirstName = addDonorViewModel.FirstName, LastName = addDonorViewModel.LastName, DateOfBirth = addDonorViewModel.DateOfBirth, Email = addDonorViewModel.Email, Address = address, ContactNum = addDonorViewModel.ContactNum, BloodGroup = addDonorViewModel.BloodGroup }; // EventData.Add(newEvent); context.Donors.Add(newDonor); context.SaveChanges(); TempData["msg"] = "New Donor Added Successfully."; if (User.Identity.IsAuthenticated) { return(Redirect("/StaffLogin")); } else { TempData["msg"] = "Thank you for volunteering!"; return(Redirect("/Home")); } } return(View(addDonorViewModel)); }
public ActionResult Create([Bind(Include = "RegId,EmailNumber,Password,DonorName,Phone,Age,Address,Qualification,Photo,ImageUrl,GroupId,GenderId")] NewRegistration newRegistration, HttpPostedFileBase FileUpload) { if (ModelState.IsValid) { //Save image in folder string FileName = Path.GetFileName(FileUpload.FileName); string SaveLocation = Server.MapPath("~/NewRegPicture/" + FileName); FileUpload.SaveAs(SaveLocation); //save image name in database newRegistration.ImageUrl = "~/NewRegPicture/" + FileName; // byte image Save newRegistration.Photo = new byte[FileUpload.ContentLength]; ViewBag.BloodDonorPic = FileUpload.InputStream.Read(newRegistration.Photo, 0, FileUpload.ContentLength); db.NewRegistrations.Add(newRegistration); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GroupId = new SelectList(db.BloodGroups, "GroupId", "GroupName", newRegistration.GroupId); ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "GenderName", newRegistration.GenderId); return(View(newRegistration)); }
public ActionResult Create([Bind(Include = "Id,Name,Phone,PatientAge,Problem,Address,HospitalName,BloodRequestDate,BloodNeedDate,Countity,Photo,PhotoPathUrl,GroupId,GenderId")] BloodRequest bloodRequest, HttpPostedFileBase FileUpload) { if (ModelState.IsValid) { //Save image in folder string FileName = Path.GetFileName(FileUpload.FileName); string SaveLocation = Server.MapPath("~/PictureFolder/" + FileName); FileUpload.SaveAs(SaveLocation); //save image name in database bloodRequest.PhotoPathUrl = "~/PictureFolder/" + FileName; // byte image Save bloodRequest.Photo = new byte[FileUpload.ContentLength]; ViewBag.BloodDonorPic = FileUpload.InputStream.Read(bloodRequest.Photo, 0, FileUpload.ContentLength); db.BloodRequests.Add(bloodRequest); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GroupId = new SelectList(db.BloodGroups, "GroupId", "GroupName", bloodRequest.GroupId); ViewBag.GenderId = new SelectList(db.Genders, "GenderId", "GenderName", bloodRequest.GenderId); return(View(bloodRequest)); }
public ActionResult Create([Bind(Include = "UserId,UserName,Password")] Admin admin) { if (ModelState.IsValid) { db.Admins.Add(admin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(admin)); }
public ActionResult Create([Bind(Include = "GroupId,GroupName")] BloodGroup bloodGroup) { if (ModelState.IsValid) { db.BloodGroups.Add(bloodGroup); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bloodGroup)); }
public ActionResult Create([Bind(Include = "GenderId,GenderName")] Gender gender) { if (ModelState.IsValid) { db.Genders.Add(gender); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gender)); }
public ActionResult Create(Area area) { if (ModelState.IsValid) { db.Areas.Add(area); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AreaId = new SelectList(db.Areas, "Id", "AreaName", area.AreaId); return(View(area)); }
public ActionResult Create(StakeHolder stakeholder) { if (ModelState.IsValid) { db.StakeHolders.Add(stakeholder); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AreaId = new SelectList(db.Areas, "Id", "AreaName", stakeholder.AreaId); return(View(stakeholder)); }
public ActionResult Create(BloodRequistion bloodrequistion) { if (ModelState.IsValid) { db.BloodRequistions.Add(bloodrequistion); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AreaId = new SelectList(db.Areas, "Id", "AreaName", bloodrequistion.AreaId); ViewBag.StakeholderId = new SelectList(db.StakeHolders, "Id", "FullName", bloodrequistion.StakeholderId); return(View(bloodrequistion)); }
public ActionResult Create(BloodDonationHistory blooddonationhistory) { if (ModelState.IsValid) { db.BloodDonationHistories.Add(blooddonationhistory); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StakeholderId = new SelectList(db.StakeHolders, "Id", "FullName", blooddonationhistory.StakeholderId); ViewBag.RequisitionId = new SelectList(db.BloodRequistions, "Id", "BloodGroup", blooddonationhistory.RequisitionId); return(View(blooddonationhistory)); }
public ActionResult Create(Notice notice) { if (ModelState.IsValid) { db.Notices.Add(notice); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.NoticeToId = new SelectList(db.StakeHolders, "Id", "FullName", notice.NoticeToId); ViewBag.NoticeById = new SelectList(db.StakeHolders, "Id", "FullName", notice.NoticeById); ViewBag.RequisitionId = new SelectList(db.BloodRequistions, "Id", "BloodGroup", notice.RequisitionId); return(View(notice)); }
public IActionResult EditDonor(AddDonorViewModel donorViewModel) { if (ModelState.IsValid) { Donor donorToEdit = context.Donors.Find(donorViewModel.Id); Address addressToEdit = context.Address.Find(donorToEdit.AddressId); donorToEdit.FirstName = donorViewModel.FirstName; donorToEdit.LastName = donorViewModel.LastName; donorToEdit.DateOfBirth = donorViewModel.DateOfBirth; donorToEdit.Email = donorViewModel.Email; donorToEdit.ContactNum = donorViewModel.ContactNum; donorToEdit.BloodGroup = donorViewModel.BloodGroup; addressToEdit.Line1 = donorViewModel.Line1; addressToEdit.Line2 = donorViewModel.Line2; addressToEdit.City = donorViewModel.City; addressToEdit.State = donorViewModel.State; addressToEdit.Zip = donorViewModel.Zip; context.Donors.Update(donorToEdit); context.Address.Update(addressToEdit); context.SaveChanges(); TempData["msg"] = "Donor Id: " + donorToEdit.Id + " updated successfully."; return(Redirect("/StaffLogin")); } return(View(donorViewModel)); }
public IActionResult EditStock(ManageStockViewModel manageStockViewModel, string radioButton, string amountToUpdate) { if (ModelState.IsValid) { BloodStock bloodStockToUpdate = context.BloodStock.Find(manageStockViewModel.Id); if (radioButton == "Increase") { bloodStockToUpdate.Quantity = manageStockViewModel.Quantity + int.Parse(amountToUpdate); } else { if (manageStockViewModel.Quantity < int.Parse(amountToUpdate)) { ModelState.AddModelError("AmountToUpdate", "Please enter a quantity less than " + manageStockViewModel.Quantity + " units"); return(View(manageStockViewModel)); } bloodStockToUpdate.Quantity = manageStockViewModel.Quantity - int.Parse(amountToUpdate); } context.BloodStock.Update(bloodStockToUpdate); context.SaveChanges(); TempData["msg"] = "Blood Group: " + bloodStockToUpdate.BloodGroup + " updated to " + bloodStockToUpdate.Quantity + " units."; return(Redirect("/ManageStock")); } return(View(manageStockViewModel)); }
public JsonResult DeleteConfirm(int id) { var DbSearchResult = db.BloodRequests.Where(b => b.id == id).FirstOrDefault(); db.BloodRequests.Remove(DbSearchResult); db.SaveChanges(); return(Json("Deleted Data Successfilly!!")); }