Esempio n. 1
0
        public StaticPage GetStaticPageById(int staticPageId)
        {
            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var cmd =
                    new SqlCommand(
                        "Select p.UserID, p.StaticPageContent,p.StatusID,s.StatusType, p.DateOfPageCreation, p.StaticPageTitle, p.StaticPageID from StaticPage p inner join [Status] s  on p.StatusID= s.StatusID where p.StaticPageID = StaticPageID order by p.DateOfPageCreation desc",
                        cn);
                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var staticPage = new StaticPage();
                        {
                            //Status = new Status(),
                            //User = new User()
                        };
                        staticPage.User.UserId= dr.GetString(0);
                        staticPage.StaticPageContent = dr.GetString(1);
                        staticPage.Status.StatusID = dr.GetInt32(2);
                        staticPage.Status.StatusType = dr.GetString(3);
                        staticPage.DateOfPageCreation = dr.GetDateTime(4);
                        staticPage.StaticPageTitle = dr.GetString(5);
                        staticPage.StaticPageID = dr.GetInt32(6);

                        return staticPage;
                    }
                }

            }
            return null;
        }
Esempio n. 2
0
        public void SaveStaticPageDBTest()
        {
            var repo = new StaticPageRepo();
            StaticPage staticPage = new StaticPage()
            {
                User = new User()
                {
                    UserId = "f319beb5-8a14-40c1-9cb5-0d6c92571ae4"
                },
                StaticPageContent = "<p>Do not do things</p>",
                StaticPageTitle = "Static Page Number 1",
                Status = new Status() { StatusID = 1 },
                DateOfPageCreation = DateTime.Now

            };
            repo.SaveStaticPage(staticPage);
            var list = repo.GetAllStaticPages();
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("Static Page Number 1", list.FirstOrDefault(x => x.StaticPageID == 1).StaticPageTitle);
        }
Esempio n. 3
0
        public List<StaticPage> GetAllStaticPages()
        {
            var staticPages = new List<StaticPage>();
            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                var cmd = new SqlCommand("Select p.UserId, p.StaticPageContent, p.StatusID, s.StatusType, p.DateOfPageCreation, p.StaticPageTitle, p.StaticPageID from StaticPage p inner join [Status] s  on p.StatusID= s.StatusID order by p.DateOfPageCreation desc", cn);
                cn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var staticPage = new StaticPage()
                        {
                            Status = new Status(),
                            User = new User()
                        };
                        staticPage.User.UserId = dr.GetString(0);
                        staticPage.StaticPageContent= dr.GetString(1);
                        staticPage.Status.StatusID = dr.GetInt32(2);
                        staticPage.Status.StatusType = dr.GetString(3);
                        staticPage.DateOfPageCreation = dr.GetDateTime(4);
                        staticPage.StaticPageTitle = dr.GetString(5);
                        staticPage.StaticPageID = dr.GetInt32(6);

                        staticPages.Add(staticPage);
                    }
                }

            }
            var repo = new UserRepo();
            foreach (var page in staticPages)
            {
                var id = page.User.UserId;
                page.User = repo.GetUserById(id);
                page.User.UserId = id;
            }
            return staticPages;
        }
        public ActionResult CreateStaticPages(StaticPageVM model)
        {
            var staticPage = new StaticPage();

            staticPage = model.NewPage;
            staticPage.StaticPageContent = model.HtmlContent;
            if (model.NewPage.Status == null)
            {
                staticPage.Status = new Status()
                {
                    StatusID = 1

                };
            }
            else
            {
                staticPage.Status.StatusID = model.NewPage.Status.StatusID;
            }
            var ops = OperationsFactory.CreateStaticPageOps();

            ops.SaveStaticPage(staticPage);

            return RedirectToAction("Index", "Home");
        }
Esempio n. 5
0
 public void SaveStaticPage(StaticPage staticPage)
 {
     if (staticPage.DateOfPageCreation > new DateTime(01 / 01 / 2000))
         _repo.SaveStaticPage(staticPage);
 }
Esempio n. 6
0
 public void SaveStaticPage(StaticPage staticPage)
 {
 }
Esempio n. 7
0
        public void SaveStaticPage(StaticPage staticPage)
        {
            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
                {
                    var p = new DynamicParameters();
                    p.Add("@UserId", staticPage.User.UserId);
                    p.Add("@StaticPageContent", staticPage.StaticPageContent);
                    p.Add("@StatusID", staticPage.Status.StatusID);
                    p.Add("@DateOfPageCreation", staticPage.DateOfPageCreation);
                    p.Add("@StaticPageTitle", staticPage.StaticPageTitle);

                    cn.Query("SaveStaticPage", p, commandType: CommandType.StoredProcedure);
                }
        }