예제 #1
0
 /*to change language*/
 public ActionResult changeLanguage(string lang)
 {
     setCurrentLanguage(lang);
     if (isUserAuthenticated())
     {//set doctor language to authenticated cookie
         userCookieData userData = Request.getUserCookieData();
         userData.lang = lang;
         string userCookiedata = new JavaScriptSerializer().Serialize(userData);
         var    cookie         = Request.Cookies[FormsAuthentication.FormsCookieName];
         var    ticket         = FormsAuthentication.Decrypt(cookie.Value);
         var    newTicket      = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, DateTime.Now.AddYears(100), ticket.IsPersistent, userCookiedata, "/" + defaultPathForUsersArea);
         cookie.Value = FormsAuthentication.Encrypt(newTicket);
         if (ticket.IsPersistent)
         {
             cookie.Expires = newTicket.Expiration;
         }
         cookie.Path = newTicket.CookiePath;
         Response.Cookies.Set(cookie);
     }
     else
     {//create temporary cookie untill doctor will be authenricated to save language value
         var cookie = Request.Cookies[userCookieDataName];
         if (cookie != null)
         {
             cookie.Values.Set("language", lang);
             cookie.Path = "/" + defaultPathForUsersArea;
             Response.Cookies.Set(cookie);
         }
         else
         {
             cookie      = new System.Web.HttpCookie(userCookieDataName);
             cookie.Path = "/" + defaultPathForUsersArea;
             cookie.Values.Add("language", lang);
             Response.Cookies.Add(cookie);
         }
     }
     if (Request.UrlReferrer == null)
     {
         return(Redirect("/" + defaultPathForUsersArea));
     }
     return(Redirect(Request.UrlReferrer.ToString()));
 }
예제 #2
0
 /*get patient(user) appointements*/
 public ActionResult appointements(bool type = true)
 {
     /*
      * type=true->function will return the booked appointements of this user at future
      * type=false->function will return the booked appointements of this user at past
      */
     try
     {
         if (type)
         {
             ViewBag.currentAppoint = "present";      //present and future appointements
         }
         else
         {
             ViewBag.currentAppoint = "past"; //previous appointements
         }
         userCookieData userData    = Request.getUserCookieData();
         Guid           currentPtID = (userData.providerName == null)
         ? db.patients.SingleOrDefault(p => p.username == userData.username).id
         : db.patients.SingleOrDefault(p => p.providerName == userData.providerName && p.providerID == userData.providerID).id;
         List <reservingData> reservingData = null;
         if (currentLanguage == "en")
         {
             reservingData = (type)
                 ?db.reservings
                             .Where(r => r.patientID == currentPtID && r.reservingDate >= DateTime.Now)
                             .Select(res => new reservingData {
                 name          = res.doctor.doctorInfo.fnameEng + " " + res.doctor.doctorInfo.lnameEng,
                 clinicAddress = res.doctor.doctorInfo.clinicAddressEng,
                 patientName   = res.patientName,
                 id            = res.id,
                 reservingDate = res.reservingDate,
                 interval      = res.interval
             }).ToList()
                 :db.reservings
                             .Where(r => r.patientID == currentPtID && r.reservingDate < DateTime.Now)
                             .Select(res => new reservingData {
                 name          = res.doctor.doctorInfo.fnameEng + " " + res.doctor.doctorInfo.lnameEng,
                 clinicAddress = res.doctor.doctorInfo.clinicAddressEng,
                 patientName   = res.patientName,
                 id            = res.id,
                 reservingDate = res.reservingDate,
                 interval      = res.interval
             }).ToList();
         }
         else
         {
             reservingData = (type)
                 ?db.reservings
                             .Where(r => r.patientID == currentPtID && r.reservingDate >= DateTime.Now)
                             .Select(res => new reservingData {
                 name          = res.doctor.doctorInfo.fnameAr + " " + res.doctor.doctorInfo.lnameAr,
                 clinicAddress = res.doctor.doctorInfo.clinicAddressAr,
                 patientName   = res.patientName,
                 id            = res.id,
                 reservingDate = res.reservingDate,
                 interval      = res.interval
             }).ToList()
                 :db.reservings
                             .Where(r => r.patientID == currentPtID && r.reservingDate < DateTime.Now)
                             .Select(res => new reservingData {
                 name          = res.doctor.doctorInfo.fnameAr + " " + res.doctor.doctorInfo.lnameAr,
                 clinicAddress = res.doctor.doctorInfo.clinicAddressAr,
                 patientName   = res.patientName,
                 id            = res.id,
                 reservingDate = res.reservingDate,
                 interval      = res.interval
             }).ToList();
         }
         return(View(reservingData));
     }
     catch
     {
         return(Redirect("/" + defaultPathForUserSite));
     }
 }