示例#1
0
        private string GetUsefulLinks(string parentOnly)
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();

            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                IUsefulLinksRepository repository = new UsefulLinksRepository(context);
                UsefulLinksService     manager    = new UsefulLinksService(repository);

                if (parentOnly == "1")
                {
                    return(jss.Serialize(manager.GetAllUsefulLinks(UsefulLinksTypeEnum.ParentOnly)));
                }
                else if (parentOnly == "0")
                {
                    return(jss.Serialize(manager.GetAllUsefulLinks(UsefulLinksTypeEnum.ChildOnly)));
                }
                else
                {
                    throw new ArgumentException("Could only get parent or child categories by this method");
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IsAuthorized"] == null)
            {
                // No login account
                Response.Redirect("../MyAccounts/NoLoginPage.aspx");
                return;
            }
            HiddenField1.Value = Page.User.Identity.Name;

            Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);

            string userName = Page.User.Identity.Name;

            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                UserService manager   = new UserService(context);
                var         user_temp = manager.GetUserByLoginName(userName);

                //if (user_temp.Sex == true)
                //{
                //    owner_image_id.ImageUrl = (user_temp.HeadPhoto == null) ? "../Images/men.jpg" : user_temp.HeadPhoto;
                //}
                //else
                //{
                //    owner_image_id.ImageUrl = (user_temp.HeadPhoto == null) ? "../Images/women.jpg" : user_temp.HeadPhoto;
                //}

                owner_name_id.Text        = user_temp.UserName;
                owner_name_id.NavigateUrl = "";
                // Get report links
                IUsefulLinksRepository repository = new UsefulLinksRepository();
                UsefulLinksService     _manager   = new UsefulLinksService(repository);

                var usefulLinks = _manager.GetAllUsefulLinks(UsefulLinksTypeEnum.ParentOnly);

                linksRept.DataSource = usefulLinks.ToList <AppUsefulLinks>();
                linksRept.DataBind();
            }
        }