Exemplo n.º 1
0
        // GET: Donation/Delete/5
        public ActionResult Delete(int id)
        {
            var donationLogEntry = bddb.DonationLog.Find(id);

            var dataToDelete = new DonationDetailsViewModel
            {
                DonationDate   = donationLogEntry.DonationDate,
                DonationCenter = donationLogEntry.DonationCenter.Name + " " + donationLogEntry.DonationCenter.DonationCenterType.Name,
                IsSuccessful   = donationLogEntry.IsSuccessful ? "✔" : "✘",
                NextDate       = donationLogEntry.NextDate,
                Comments       = donationLogEntry.Comments
            };

            return(PartialView("_Delete", dataToDelete));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            var donationLogEntry = bddb.DonationLog.Find(id);

            try
            {
                bddb.DonationLog.Remove(donationLogEntry);
                bddb.SaveChanges();

                return(Json(new { success = true }));
            }
            catch
            {
                var dataToDelete = new DonationDetailsViewModel
                {
                    DonationDate   = donationLogEntry.DonationDate,
                    DonationCenter = donationLogEntry.DonationCenter.Name + " " + donationLogEntry.DonationCenter.DonationCenterType.Name,
                    IsSuccessful   = donationLogEntry.IsSuccessful ? "✔" : "✘",
                    NextDate       = donationLogEntry.NextDate,
                    Comments       = donationLogEntry.Comments
                };
                return(PartialView("_Delete", dataToDelete));
            }
        }