public ActionResult EditDonation(int?ida, int?idb) { if (ida == null || idb == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DONATION donation = dnRepo.FindById(ida, idb); if (donation == null) { return(HttpNotFound()); } ViewBag.TypeOf = new SelectList(ddlData.TYPEOF, "TypeOf", "TypeOf", donation.TypeOf); ViewBag.GiftMethod = new SelectList(ddlData.GIFTMETHOD, "GiftMethod", "GiftMethod", donation.GiftMethod); ViewBag.Fund = new SelectList(ddlData.FUNDS, "Fund", "Fund", donation.Fund); ViewBag.DonorId = new SelectList(ddlData.DONOR, "DONORID", "FNAME", donation.DonorId); ViewBag.GL = new SelectList(ddlData.GLS, "GL", "GL", donation.GL); ViewBag.Department = new SelectList(ddlData.DEPARTMENTS, "Department", "Department", donation.Department); ViewBag.Program = new SelectList(ddlData.PROGRAMS, "Program", "Program", donation.Program); ViewBag.Grant = new SelectList(ddlData.GRANTS, "GrantName", "GrantName", donation.GrantS); return(View("~/Views/DONATIONs/DonorEdit.cshtml", donation)); }
// GET: DONATIONs/Delete/5 public ActionResult Delete(int?ida, int?idb) { if (ida == null || idb == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DONATION donation = dnRepo.FindById(ida, idb); if (donation == null) { return(HttpNotFound()); } if (donation.FILES.Count > 0) { return(RedirectToAction("Edit", "DONATIONs", new { ida = ida, idb = idb, })); } else { ViewBag.TypeOf = new SelectList(ddlData.DONATION, "TypeOf"); } ViewBag.GiftMethod = new SelectList(ddlData.DONATION, "GiftMethod"); return(View(donation)); }
public void SaveDonation(DONATION d) { if (d.DonationId == 100) { context.DONATION.Add(d); } else { DONATION dbEntry = context.DONATION.Find(d.DonationId, d.DonorId); if (dbEntry != null) { dbEntry.Amount = d.Amount; dbEntry.TypeOf = d.TypeOf; dbEntry.DateRecieved = d.DateRecieved; dbEntry.GiftMethod = d.GiftMethod; dbEntry.DateGiftMade = d.DateGiftMade; dbEntry.GiftRestrictions = d.GiftRestrictions; dbEntry.Notes = d.Notes; dbEntry.Appeal = d.Appeal; dbEntry.Department = d.Department; dbEntry.Fund = d.Fund; dbEntry.GL = d.GL; dbEntry.GrantS = d.GrantS; dbEntry.Program = d.Program; dbEntry.FILES = d.FILES; } } context.SaveChanges(); }
public void Remove(int ida, int idb) { DONATION d = context.DONATION.Find(ida, idb); context.DONATION.Remove(d); context.SaveChanges(); }
public ActionResult AddDonation(DONATION myDonation, IEnumerable <HttpPostedFileBase> image) { DONATION donation = myDonation; List <FILES> myList = new List <FILES>(); if (ModelState.IsValid) { foreach (var item in image) { if (item != null && item.ContentLength > 0) { var myImage = new FILES { FileName = System.IO.Path.GetFileName(item.FileName), ContentType = item.ContentType, DonationId = donation.DonationId, DonorId = donation.DonorId }; using (var reader = new System.IO.BinaryReader(item.InputStream)) { myImage.Content = reader.ReadBytes(item.ContentLength); } myList.Add(myImage); } donation.FILES = myList; } dnRepo.Add(donation); return(RedirectToAction("Details", "DONORs", new { id = donation.DonorId })); } ViewBag.TypeOf = new SelectList(ddlData.TYPEOF, "TypeOf", "TypeOf"); ViewBag.GiftMethod = new SelectList(ddlData.GIFTMETHOD, "GiftMethod", "GiftMethod"); ViewBag.DonorId = new SelectList(ddlData.DONOR, "DONORID", "FNAME", donation.DonorId); ViewBag.Fund = new SelectList(ddlData.FUNDS, "Fund", "Fund"); ViewBag.GL = new SelectList(ddlData.GLS, "GL", "GL"); ViewBag.Department = new SelectList(ddlData.DEPARTMENTS, "Department", "Department"); ViewBag.Program = new SelectList(ddlData.PROGRAMS, "Program", "Program"); ViewBag.Grant = new SelectList(ddlData.GRANTS, "GrantName", "GrantName"); return(View("~/Views/DONATIONs/DonorCreate.cshtml", donation)); }
public ActionResult EditDonation([Bind(Include = "DonationId,DonorId,Amount,TypeOf,DateRecieved,GiftMethod,DateGiftMade,GiftRestrictions,Notes,Fund,GL,Department,Program,GrantS,Appeal")] DONATION dONATION, IEnumerable <HttpPostedFileBase> image) { List <FILES> myList = new List <FILES>(); if (ModelState.IsValid) { foreach (var item in image) { if (item != null && item.ContentLength > 0) { var check = new FILES { FileName = System.IO.Path.GetFileName(item.FileName), ContentType = item.ContentType, DonationId = dONATION.DonationId, DonorId = dONATION.DonorId }; using (var reader = new System.IO.BinaryReader(item.InputStream)) { check.Content = reader.ReadBytes(item.ContentLength); } myList.Add(check); } dONATION.FILES = myList; } dnRepo.SaveDonation(dONATION); return(RedirectToAction("Details", "DONORs", new { id = dONATION.DonorId })); } ViewBag.TypeOf = new SelectList(ddlData.DONATION, "TypeOf", "TypeOf"); ViewBag.GiftMethod = new SelectList(ddlData.DONATION, "GiftMethod", "GiftMethod"); ViewBag.Fund = new SelectList(ddlData.FUNDS, "Fund", "Fund"); ViewBag.DonorId = new SelectList(ddlData.DONOR, "DONORID", "FNAME", dONATION.DonorId); ViewBag.GL = new SelectList(ddlData.GLS, "GL", "GL"); ViewBag.Department = new SelectList(ddlData.DEPARTMENTS, "Department", "Department"); ViewBag.Program = new SelectList(ddlData.PROGRAMS, "Program", "Program"); ViewBag.Grant = new SelectList(ddlData.GRANTS, "GrantName", "GrantName"); return(View(dONATION)); }
public FileContentResult GetImageTwo(int donationId, int donorId) { DONATION donation = dnRepo.FindById(donationId, donorId); IEnumerable <FILES> file = donation.FILES; if (file.ElementAt(1).Content != null && file.ElementAt(1).Content.Length > 0) { byte[] secPhoto = file.ElementAtOrDefault(1).Content; return(File(secPhoto, "image/png")); } else { return(null); } }
public FileContentResult GetImageOne(int donationId, int donorId) { DONATION donation = dnRepo.FindById(donationId, donorId); IEnumerable <FILES> file = donation.FILES; if (file.Count() > 0) { byte[] firstPhoto = file.ElementAtOrDefault(0).Content; return(File(firstPhoto, "image/png")); } else { return(null); } }
// GET: DONATIONs/Details/5 public ActionResult Details(int?ida, int?idb) { //if both the donor and donation id = 0 return a bad request message if (ida == null || idb == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DONATION donation = dnRepo.FindById(ida, idb); if (donation == null) { return(HttpNotFound()); } return(View(donation)); }
public ActionResult RemoveImageTwo(int donationId, int donorId) { DONATION donation = dnRepo.FindById(donationId, donorId); IEnumerable <FILES> file = donation.FILES; if (file.ElementAt(1).Content != null && file.ElementAt(1).Content.Length > 0) { donation.FILES.Remove(file.ElementAt(1)); dnRepo.SaveDonation(donation); return(RedirectToAction("Edit", new { ida = donationId, idb = donorId })); } else { return(null); } }
public void Add(DONATION d) { context.DONATION.Add(d); context.SaveChanges(); }