using HealthchoiceMVC.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Microsoft.AspNet.Identity; using HealthchoiceMVC.Services; using HealthchoiceMVC.NonDbModels; namespace HealthchoiceMVC.Controllers { public class HomeController : Controller { private ApplicationDbContext dbUser = new ApplicationDbContext(); //to access users private HCDBEntities db = new HCDBEntities(); //to access HCDB private HCLocalService service = new HCLocalService(); public ActionResult Index() { if (User.Identity.IsAuthenticated) { ApplicationUser currentuser = dbUser.Users.Find(User.Identity.GetUserId()); string PageMessage = "

Welcome back " + currentuser.FirstName + "!

"; ; ViewBag.EmailConfirmed = currentuser.EmailConfirmed; ViewBag.UserId = currentuser.Id; string userType = ""; if (currentuser.EmailConfirmed == false) { PageMessage = "

Welcome to Healthchoice " + currentuser.FirstName + "!

An email was sent to your captured email address for confirmation of the captured address. Please complete the registration process by clicking on the link provided in the email. If you have not received the email after a few minutes you can resend it by clicking on the button below"; } else if (currentuser.AccountType==4) //Provider { bool isConfirmed = false; foreach(var role in currentuser.Roles) { if (role.ToString() == "Provider") { isConfirmed = true; } } if(isConfirmed==false) PageMessage = "

Welcome back " + currentuser.FirstName + "!

You have completed the first part of your registration. The validation of your details is in progress and may take up to 48 hours at which point you’ll receive a contract document from us. Please complete this by initialling each page and signing the last page and then fax / email the completed document to (086) 730-3236 or contracts@healthchoice.co.za. If 48 hours has passed since you have registered and have not heard back from us yet, please alert us to this on 0860blablabla or to contracts@healthchoice.co.za.

"; } ViewBag.PageMessage = PageMessage; ViewBag.UserType = "

"+userType+"

"; } return View(); } public ActionResult About() { ViewBag.Message = "About Healthchoice"; return View(); } public ActionResult Terms() { ViewBag.Message = "Terms and Conditions"; return View(); } public ActionResult FAQ() { ViewBag.Message = "Frequently asked questions"; return View(); } public ActionResult Contact() { ViewBag.Message = "Contact us page"; return View(); } public ActionResult AccountRedirect() { ApplicationUser user = new ApplicationUser(); user = service.GetCurrentUserByName(User.Identity.Name); switch (user.AccountType) { case 1: //Healthchoice User return View(); //break; case 2: //Patient return View(); //break; case 3://MHC User return View(); //break; case 4://Provider int prov_key = db.user_link.Where(u => u.UserId == user.Id.ToString()).FirstOrDefault().entity_key; return RedirectToAction("Edit", "Provider", new {Id = prov_key }); } return View(); } } }