示例#1
0
        public void AddPage(Page page)
        {
            const string commandString = @"INSERT INTO Pages
                         (Title,Active,Detail,LinkTitle) VALUES (@Title,@Active,@Detail,@LinkTitle)";

            try
            {
                using (var connection = new SqlConnection(ConnectionString))
                {
                    connection.Open();
                    var command = new SqlCommand(commandString, connection);
                    command.Parameters.Add("@Title", page.Title);
                    command.Parameters.Add("@Detail", page.Detail);
                    command.Parameters.Add("@Active", page.Active);
                    command.Parameters.Add("@LinkTitle", page.LinkTitle);

                    command.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {

                throw new Exception(ex.ToString());
            }
        }
示例#2
0
        public ActionResult ChangepageStatus(int pageId, bool Value)
        {
            Page obj = new Page();

            obj = _adminRepository.GetPageById(pageId );

            if (obj != null)
            {
                obj.Active = Value;
            }
            _adminRepository.UpdatePageStatus(obj);
            return Json(new { Message = " Page Status Changed Successfully", Success = true });
        }
示例#3
0
        public ActionResult SavePage(Page page)
        {
            if (Request.Form["PageId"] == "0")
            {

                _adminRepository.AddPage(page);
            }

            else
            {
                _adminRepository.UpdatePage (page);

            }

            PageModel obj = new PageModel ();

            obj.listpage  = _adminRepository.GetAllPages ();

            return View("ManagePages", obj);
        }
示例#4
0
        //pages
        public void UpdatePageStatus(Page page)
        {
            const string commandString = @"Update Pages SET Active = @Active WHERE PageId=@PageId";

            try
            {
                using (var connection = new SqlConnection(ConnectionString))
                {
                    connection.Open();
                    var command = new SqlCommand(commandString, connection);
                    command.Parameters.Add("@PageId", page.PageId );
                    command.Parameters.Add("@Active", page.Active);

                    command.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {

                throw new Exception(ex.ToString());
            }
        }
示例#5
0
        public Page GetPageById(int pageid)
        {
            const string commandString =
                @"SELECT Detail, Title, Active,PageId,LinkTitle FROM pages WHERE PageId = @PageId";

            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                var command = GetCommand(commandString, connection, CommandType.Text);

                var obj = new Page();
                {

                    command.Parameters.Add("@PageId", pageid );
                    {
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {

                                obj.PageId   = (int)reader["pageId"];
                                obj.Title = (string)reader["Title"];
                                obj.Detail = (string)reader["Detail"];
                                obj.LinkTitle = (string)reader["LinkTitle"];
                                obj.Active = Convert.ToBoolean(reader["Active"]);

                            }

                        }
                    }
                }

                return obj;
            }
        }
示例#6
0
        public List<Page> GetAllPages()
        {
            const string commandString =
                @"SELECT PageId, Title, Active,Detail,Title,LinkTitle FROM Pages";

            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                var command = GetCommand(commandString, connection, CommandType.Text);

                var objlist = new List<Page>();
                {

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var obj = new Page();
                            obj.PageId  = (int)reader["PageId"];
                            obj.Title = (string)reader["Title"];
                            obj.Detail = (string)reader["Detail"];
                            obj.LinkTitle = (string)reader["LinkTitle"];
                            obj.Active = Convert.ToBoolean(reader["Active"]);
                            objlist.Add(obj);
                        }

                    }
                }

                return objlist;
            }
        }