public ActionResult SaveUser(RegistrationAndLogin registrationAndLogin, string day, string month, string year)
        {
            var dateOfBirth = new DateTime(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day));

            registrationAndLogin.Registration.DateOfBirth = dateOfBirth;
            int rowsAffected = 0;

            try
            {
                rowsAffected = _registrationManager.SaveUser(registrationAndLogin.Registration);
                if (rowsAffected > 0)
                {
                    ViewBag.Message = "Saved successfully";
                }
                else
                {
                    ViewBag.Message = "Save failed";
                }
            }
            catch (Exception exception)
            {
                ViewBag.Message = exception.Message;
            }

            ViewBag.Days   = DaysDropDown();
            ViewBag.Months = MonthDropDown();
            ViewBag.Years  = YearList();

            return(View());
        }
Example #2
0
        public JsonResult UserAuthentication(RegistrationAndLogin registrationAndLogin)
        {
            var user = new User()
            {
                Email    = registrationAndLogin.Login.EmailForLogin,
                Password = registrationAndLogin.Login.PasswordForLogin
            };

            if (_loginManager.isValidUser(user))
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public RedirectResult Login(RegistrationAndLogin registrationAndLogin)
        {
            User user = new User()
            {
                Email    = registrationAndLogin.Login.EmailForLogin,
                Password = registrationAndLogin.Login.PasswordForLogin
            };

            if (_loginManager.isValidUser(user))
            {
                Session["UserId"]  = _userManager.GetUserByEmail(user.Email).Id;
                Session["User"]    = user;
                Session["Message"] = null;
                return(Redirect("/NewsFeed/Index"));
            }
            else
            {
                Session["Message"] = "Wrong username or password";
                return(Redirect("/Registration/SaveUser"));
            }
        }
        public ActionResult Report1(List <int> SchoolIds, List <string> UserTypes, int cpageno = 1, int rpageno = 1, int apageno = 1, int pagesize = 0)
        {
            if (pagesize <= 0)
            {
                pagesize = _pageSize;
            }

            var target = Request.QueryString["target"];

            if (target == "created")
            {
                var apimodel = _webClient.DownloadData <APIPagedList <StudentRegistrationModel> >("getregistrationandloginreportlist", new { UserType = UserTypes != null ? string.Join(",", UserTypes) : "", SchoolIds = SchoolIds != null ? string.Join(",", SchoolIds) : "", PageSize = pagesize, PageIndex = cpageno, Type = "created" });
                var model    = new PagedList <StudentRegistrationModel>(apimodel.Items, cpageno, pagesize, apimodel.TotalItems);
                return(PartialView("_Report1ListPost", model));
            }
            else if (target == "registered")
            {
                var apimodel = _webClient.DownloadData <APIPagedList <StudentRegistrationModel> >("getregistrationandloginreportlist", new { UserType = UserTypes != null ? string.Join(",", UserTypes) : "", SchoolIds = SchoolIds != null ? string.Join(",", SchoolIds) : "", PageSize = pagesize, PageIndex = rpageno, Type = "registered" });
                var model    = new PagedList <StudentRegistrationModel>(apimodel.Items, rpageno, pagesize, apimodel.TotalItems);
                return(PartialView("_Report1ListPost2", model));
            }
            if (target == "active")
            {
                var apimodel = _webClient.DownloadData <APIPagedList <StudentRegistrationModel> >("getregistrationandloginreportlist", new { UserType = UserTypes != null ? string.Join(",", UserTypes) : "", SchoolIds = SchoolIds != null ? string.Join(",", SchoolIds) : "", PageSize = pagesize, PageIndex = apageno, Type = "active" });
                var model    = new PagedList <StudentRegistrationModel>(apimodel.Items, apageno, pagesize, apimodel.TotalItems);
                return(PartialView("_Report1ListPost3", model));
            }
            else
            {
                var apimodel = _webClient.DownloadData <RegistrationAndLoginResult>("getregistrationandloginreport", new { UserType = UserTypes != null ? string.Join(",", UserTypes) : "", SchoolIds = SchoolIds != null ? string.Join(",", SchoolIds) : "", PageSize = pagesize, PageIndex = cpageno });
                RegistrationAndLogin model = new RegistrationAndLogin();
                model.Created     = new PagedList <StudentRegistrationModel>(apimodel.Created.Items, cpageno, pagesize, apimodel.Created.TotalItems);
                model.Registered  = new PagedList <StudentRegistrationModel>(apimodel.Registered.Items, cpageno, pagesize, apimodel.Registered.TotalItems);
                model.Active      = new PagedList <StudentRegistrationModel>(apimodel.Active.Items, cpageno, pagesize, apimodel.Active.TotalItems);
                ViewBag.Page      = "cpageno";
                ViewBag.Type      = "created";
                ViewBag.Container = "CreatedContainer";
                return(PartialView("~/Views/Report/_Report1.cshtml", model));
            }
        }