public ActionResult ChangeAccountEmail()
 {
     if ((string)Session["userCode"] == "tourist")
     {
         int TouristId = (int)Session["TouristId"];
         TouristChangeEmailViewModel tcevm = new TouristChangeEmailViewModel();
         tcevm.TouristId    = TouristId;
         tcevm.TouristEmail = (from c in entity.Tourists where c.TouristId == tcevm.TouristId select c.TouristEmail).FirstOrDefault();
         return(View(tcevm));
     }
     else
     {
         Session["user"] = "******";
         return(RedirectToAction("Index", "Home"));
     }
 }
 public ActionResult ChangeAccountEmail(TouristChangeEmailViewModel tcevm)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Tourist tourist = (from c in entity.Tourists where c.TouristId == tcevm.TouristId select c).FirstOrDefault();
             if (tourist.TouristEmail == tcevm.TouristEmail)
             {
                 return(RedirectToAction("UserPanel", "Home"));
             }
             else
             {
                 bool result = tl.CheckEmailExist(tcevm.TouristEmail);
                 if (result == true)
                 {
                     ViewData["message"] = "Email duplicacy found.";
                     return(View(tcevm));
                 }
                 else
                 {
                     tourist.TouristEmail = tcevm.TouristEmail;
                     if (entity.SaveChanges() > 0)
                     {
                         return(RedirectToAction("UserPanel", "Home"));
                     }
                     else
                     {
                         ViewData["message"] = "There's a problem going on. please try again later.";
                         return(View(tcevm));
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             return(View("Error", new HandleErrorInfo(ex, "Tourist", "ChangeAccountEmail")));
         }
     }
     else
     {
         return(View(tcevm));
     }
 }