コード例 #1
0
        public ActionResult DoRVCancel(int id) // id=ReservationId
        {
            bool        sendSuccess = false;
            Reservation r           = new Reservation();

            r = ReservationRepository.GetReservationById(id);
            BizInfo bi = BizInfoRepository.GetBizInfoById(r.BizRVInfo.BizInfoId);

            if (r.Active)
            {
                ReservationRepository.LockReservation(r);
                EmailManager  em = new EmailManager();
                EmailContents ec = new EmailContents("FoodReady.Net", r.Email, Globals.Settings.ContactForm.MailFrom,
                                                     "Reservation cancelled", EmailManager.BuildRVCancelToCustomer(r));

                em.FaxBody = EmailManager.BuildRVCancelToRestaurant(r);
                em.SendFax(bi.Fax);
                em.Send(ec); // send to customer

                if (em.IsSent == false)
                {
                    sendSuccess = false;
                    TempData["sentCustomerMsg"] = "Your message has not been sent out for some reasons.";
                }
                else
                {
                    sendSuccess = true;
                    TempData["sentCustomerMsg"] = "Your message has  been sent out successfully.";
                }
                ec.FromName         = "FoodReady.Net";
                ec.To               = bi.ContactInfo.Email; // to restaurant;
                ec.FromEmailAddress = Globals.Settings.ContactForm.MailFrom;
                ec.Subject          = "Reservation cancelled";
                ec.Body             = EmailManager.BuildRVCancelToRestaurant(r);
                em.Send(ec);
                if (em.IsSent == false)
                {
                    sendSuccess = false;
                    TempData["sentRestaurantMsg"] = "Your message has not been sent out for some reasons.";
                }
                else
                {
                    sendSuccess = true;
                    TempData["sentRestaurantMsg"] = "Your message has  been sent out successfully.";
                }
            }
            ViewBag.SendingSuccess = sendSuccess;
            return(PartialView());
        }