コード例 #1
0
        public ActionResult Login()
        {
            if (HttpContext.User.Identity.Name != "")
            {
                int userId = Convert.ToInt32(HttpContext.User.Identity.Name);


                UserTypeResponse userTypeResponse = TheDataStore.getUserType(userId);

                if (userTypeResponse.response.isOk)
                {
                    switch (userTypeResponse.type)
                    {
                    case UserType.teacher:
                        return(RedirectToAction("Teacher"));

                    case UserType.student:
                        return(RedirectToAction("Student"));
                    }
                    ;
                }
            }


            LoginPageModelResponse pageModelResponse = TheDataStore.FetchLoginPageModel();

            LoginPageModel pageModel = pageModelResponse.pageModel;

            return(View(pageModel));
        }
コード例 #2
0
        public UserTypeResponse Read(long CatID)
        {
            UserTypeResponse response = new UserTypeResponse();

            try
            {
                using (IDbConnection conn = GetConnection())
                {
                    response.usertype = conn.Get <UserTypes>(CatID);
                    if (response.usertype != null)
                    {
                        response.Status      = true;
                        response.Description = "Successful";
                    }
                    else
                    {
                        response.Status      = false;
                        response.Description = "No data";
                    }
                }
            }
            catch (Exception ex)
            {
                response.Status      = false;
                response.Description = ex.Message;
            }
            return(response);
        }
コード例 #3
0
        public IEnumerable <UserTypeResponse> GetUserTypes()
        {
            var usertypeDataList = new List <UserTypeResponse>();
            var response         = dbService.ExecuteReader("select * from UserType");

            foreach (DataRow row in response.Rows)
            {
                var userTypeData = new UserTypeResponse();
                userTypeData.TypeId   = Convert.ToInt32(row["ID"]);
                userTypeData.TypeName = Convert.ToString(row["Description"]);
                usertypeDataList.Add(userTypeData);
            }
            return(usertypeDataList);
        }