Exemplo n.º 1
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     MongoDao.Initialize();
 }
Exemplo n.º 2
0
        public string GetMDB()
        {
            var database = MongoDao.GetMongoDatabase();

            if (database == null)
            {
                return("database is null");
            }
            else
            {
                return(database.DatabaseNamespace.DatabaseName);
            }
        }
Exemplo n.º 3
0
        public ActionResult CheckLogin(string username, string passworld, string isPOrA)
        {
            if (isPOrA == "Person")
            {
                pService = new PersonService(new PersonDao());
                Person person = pService.GetOne(username, passworld);
                if (person == null)
                {
                    return(Redirect("~/Home/Login"));
                }
                var database   = MongoDao.GetMongoDatabase();
                var collection = database.GetCollection <BsonDocument>("People");
                collection.InsertOne(BsonDocument.Parse(person.ToString()));
                HttpCookie cookie = new HttpCookie("person");
                cookie.Value = person.ToString();
                //Response.Cookies.Add(cookie);
                HttpContext.Response.Cookies.Add(cookie);
                HttpContext.User = new PersonPrincipal(person);

                //HttpContext.Session.Add("person", person);
                //System.Web.HttpContext.Current.Session.Add("person", person);
                //TempData.Add("person", person);
                ViewData.Add(person.Id.ToString(), person);
                return(RedirectToAction("Index", "Person"));
            }
            else if (isPOrA == "Admin")
            {
                aService = new AdminService(new AdminDao());
                Admin admin = aService.GetOne(username, passworld);
                if (admin == null)
                {
                    return(Redirect("~/Home/Login"));
                }
                HttpCookie cookie = new HttpCookie("admin");
                cookie.Value = admin.ToString();
                HttpContext.Response.Cookies.Add(cookie);
                ViewData.Add(admin.Id.ToString(), admin);
                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                return(View("~/Views/Home/Login.cshtml"));
            }
        }