//public ActionResult Create([Bind(Include = "ReceiverID,Name,Email,Phone")] ReceiverData receiverData, int donationId) public async Task <ActionResult> Create([Bind(Include = "ReceiverID,Name,Email,Phone")] ReceiverData receiverData, int donationId, string d) { if (ModelState.IsValid) { db.ReceiverData.Add(receiverData); db.SaveChanges(); List <ReceiverData> recieverdataMathces = db.ReceiverData.Where(r => r.Email == receiverData.Email && r.Name == receiverData.Name && r.Phone == receiverData.Phone).OrderByDescending(r => r.ReceiverID).ToList(); db.MatchUp.Add(new MatchUp() { DonationID = donationId, ReceiverID = recieverdataMathces[0].ReceiverID }); db.SaveChanges(); DonationData done = new DonationData(); done.DonationID = donationId; DonationData data = db.DonationData.Where(r => r.DonationID == donationId).Single(); //-------------- full url---------- var fullURL = this.Url.Action("edit", "donations", new { id = donationId }, this.Request.Url.Scheme); var body = $"Hello {data.Name},<br /> a user is interested in your donation. Here is the contact info:<br/> {receiverData.Name}<br />{receiverData.Phone}<br />{receiverData.Email}.<br /><br /> Please flag post after it is picked up by following thie link <br />{fullURL}."; var sendTo = data.Email; await RequsetToDonor(sendTo, "*****@*****.**", body); // return RedirectToAction("Sent"); //return RedirectToAction("", "Donations"); return(View("RequestSuccess")); } return(View(receiverData)); }
public ActionResult DeleteConfirmed(int id) { DonationData donationData = db.DonationData.Find(id); db.DonationData.Remove(donationData); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "DonationID,Name,Email,Phone,FoodType,Location,PickupDate,PickupTime,ExpireTime,shortDescription")] DonationData donationData) { if (ModelState.IsValid) { db.Entry(donationData).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(donationData)); }
public ActionResult Create(int id) { DonationData donationdata = db.DonationData.Find(id); if (donationdata == null) { donationdata = new DonationData(); } ViewBag.donationdata = donationdata; return(View()); }
// GET: DonationDatas/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DonationData donationData = db.DonationData.Find(id); if (donationData == null) { return(HttpNotFound()); } return(View(donationData)); }
public ActionResult SetFlag(int?id) { if (id == null) { return(RedirectToAction("Index")); } DonationData donationData = db.DonationData.Find(id); if (donationData == null) { return(HttpNotFound()); } donationData.Flag = "inactive"; db.SaveChanges(); return(RedirectToAction("Index")); }
//public ActionResult Create([Bind(Include = "DonationID,Name,Email,Phone,FoodType,Location,PickupDate,PickupTime,ExpireTime,shortDescription")] DonationData donationData) public async Task <ActionResult> Create([Bind(Include = "DonationID,Name,Email,Phone,FoodType,Location,PickupDate,PickupTime,ExpireTime,shortDescription")] DonationData donationData) { if (ModelState.IsValid) { db.DonationData.Add(donationData); db.SaveChanges(); //----------------------------- Sending email to donor with the edit link--------------------------------------- int donationId = donationData.DonationID; var fullURL = this.Url.Action("edit", "donations", new { id = donationId }, this.Request.Url.Scheme); var body = $"Hello {donationData.Name},<br /><br /> Thank you for your donation. Here is the link to edit and/or remove your post.<br />{fullURL} <br/>Please remember to flag your post after it is picked up by selecting the flag button."; var sendTo = donationData.Email; await RequsetToDonor(sendTo, "*****@*****.**", body); //return RedirectToAction("Index"); return(View("DonationSuccess")); } return(View(donationData)); }