Ejemplo n.º 1
0
        public ActionResult SelectSvcDate()
        {
            string        strPastDate = "";
            string        strDay      = "";
            string        strDate     = "";
            string        strSpaces   = "      ";
            List <string> availDts    = new List <string>();

            uls_dbDataContext ulsdb_dc = new uls_dbDataContext();

            if (Session["PastServiceDate"] != null)
            {
                strPastDate = Convert.ToString(Session["PastServiceDate"]);
                DateTime pastDt = Convert.ToDateTime(strPastDate);
                strDay = String.Format("{0:ddd}", pastDt).ToUpper();
            }

            if (strPastDate.Length > 0)
            {
                availDts.Add(strDay + Server.HtmlDecode(strSpaces) + strPastDate);
            }
            else
            {
                IEnumerable <DateTime> availDates = ulsdb_dc.GetAvailSvcDates();

                foreach (DateTime dt in availDates)
                {
                    strDay  = String.Format("{0:ddd}", dt).ToUpper();
                    strDate = String.Format("{0:MM/dd/yyyy}", dt);
                    availDts.Add(strDay + Server.HtmlDecode(strSpaces) + strDate);
                }
            }



            ViewData["AvailableDates"] = new SelectList(availDts);
            ViewData["SaveResultMsg"]  = Session["SaveResultMsg"];

            svc_contact sc = ulsdb_dc.svc_contacts.Single(s => s.contact_id == 1);

            ViewData["ContactName"]  = sc.contact_name;
            ViewData["ContactPhone"] = sc.contact_number;
            ViewData["ContactEmail"] = sc.contact_email;
            ViewData["NotifyEmail1"] = sc.notify1_email;
            ViewData["NotifyEmail2"] = sc.notify2_email;
            ViewData["NotifyEmail3"] = sc.notify3_email;

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult ReSchedPhoneSave()
        {
            uls_dbDataContext db = new uls_dbDataContext();
            string            strDay;
            string            strDate;
            string            strSpaces = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            List <string>     availDts  = new List <string>();

            string strHomePhone = System.Text.RegularExpressions.Regex.Replace(Request.Form["txtHomePhone"], "\\D", "");

            try
            {
                svc_appointment sa = db.svc_appointments.SingleOrDefault(a => a.home_phone == strHomePhone && a.svc_date > DateTime.Now);

                if (sa == null)
                {
                    svc_contact sc = db.svc_contacts.Single(s => s.contact_id == 1);

                    string strName  = sc.contact_name;
                    string strPhone = sc.contact_number;
                    string strEmail = sc.contact_email;


                    throw new Exception("The phone number supplied is not on record as having a scheduled service. If you feel this message " +
                                        "is in error please call or email " + strName + " (" + strEmail + ")" + " at " + strPhone + ".");
                }


                Session["txtHomePhone"]  = strHomePhone;
                Session["txtCity"]       = sa.city;
                Session["txtEmail"]      = sa.email;
                Session["FName"]         = sa.first_name;
                Session["LName"]         = sa.last_name;
                Session["txtHomePhone"]  = sa.home_phone;
                Session["txtOtherPhone"] = sa.other_phone;
                Session["ddlState"]      = sa.state;
                Session["txtAddress"]    = sa.street_address;
                Session["txtZip"]        = sa.zip;
                Session["txtNotes"]      = sa.comments;

                IEnumerable <DateTime> availDates = db.GetAvailSvcDates();


                foreach (DateTime dt in availDates)
                {
                    if (dt > DateTime.Now.AddDays(3))
                    {
                        strDay  = String.Format("{0:ddd}", dt).ToUpper();
                        strDate = String.Format("{0:MM/dd/yyyy}", dt);
                        availDts.Add(strDay + Server.HtmlDecode(strSpaces) + strDate);
                    }
                }

                Session["ReSchedule"] = "Yes";

                ViewData["AvailableDates"] = new SelectList(availDts);

                return(RedirectToAction("SelectSvcDate"));
            }
            catch (Exception ex)
            {
                string msg = ex.Message;

                Session["SaveResultMsg"]  = msg;
                Session["SaveResultName"] = "Sorry!";

                Session["ShowReturnLink"] = "Yes";

                return(RedirectToAction("SvcDateResult"));
            }
        }