Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpPostedFile thumb      = context.Request.Files["thumb"];
            string         thumb_file = "";

            if (thumb.ContentLength > 0)
            {
                string sfiletype1 = thumb.FileName;
                sfiletype1 = sfiletype1.Substring(sfiletype1.LastIndexOf('.') + 1).ToLower();
                thumb_file = Guid.NewGuid().ToString() + "." + sfiletype1;
                string _path1 = context.Server.MapPath("~/Media");
                thumb.SaveAs(_path1 + "/" + thumb_file);
            }

            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            string title   = context.Request["title"];
            string artitle = context.Request["artitle"];
            School school  = new School {
                title = title, thumb = thumb_file, artitle = artitle
            };

            school = db.Schools.Add(school);

            db.SaveChanges();
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int schoolId = int.Parse(context.Request["schoolId"]);
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            var books = db.Books.ToList();
            var ps    = db.SchoolBooks.Where(x => x.schoolId == schoolId).ToList();

            foreach (var p in ps)
            {
                db.SchoolBooks.Remove(p);
            }
            foreach (var book in books)
            {
                string spon = context.Request["book" + book.id];

                if (spon == "true")
                {
                    db.SchoolBooks.Add(new SchoolBook {
                        schoolId = schoolId, bookId = book.id
                    });
                }
                else
                {
                    var r = db.SchoolBooks.Where(x => x.schoolId == schoolId && x.bookId == book.id).SingleOrDefault();
                    if (r != null)
                    {
                        db.SchoolBooks.Remove(r);
                    }
                }
            }
            db.SaveChanges();
            context.Response.Write("success");
        }
Example #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpFileCollection thumbs = context.Request.Files;
            int bookId = int.Parse(context.Request["bookId"]);
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int iorder    = 1;
            var lastslide = db.BookSlides.Where(x => x.bookId == bookId).OrderByDescending(x => x.OrderIndex).FirstOrDefault();

            if (lastslide != null)
            {
                iorder = (int)lastslide.OrderIndex;
                iorder++;
            }
            for (int i = 0; i < thumbs.Count; i++)
            {
                HttpPostedFile thumb     = thumbs[i];
                string         sfiletype = thumb.FileName;
                sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower();
                string thumb_file = Guid.NewGuid().ToString() + "." + sfiletype;
                string _path      = context.Server.MapPath("~/Media");
                thumb.SaveAs(_path + "/" + thumb_file);


                db.BookSlides.Add(new BookSlide {
                    img = thumb_file, bookId = bookId, OrderIndex = iorder
                });
                iorder++;
            }
            db.SaveChanges();
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int imId = int.Parse(context.Request["id"]);
            var row  = db.Books.Where(x => x.id == imId).SingleOrDefault();

            switch (context.Request["field"])
            {
            case "thumb":
                row.thumb = SaveImage(context, context.Request["img"]);
                break;

            case "pdf":
                row.pdf = SavePdf(context, context.Request["img"]);
                string    pdfPath = context.Server.MapPath("~/Media/") + row.pdf;
                PdfReader reader  = new PdfReader(pdfPath);
                int       iorder  = 1;
                var       slides  = db.BookSlides.Where(x => x.bookId == row.id).ToList();
                db.BookSlides.RemoveRange(slides);
                for (int page = 1; page <= reader.NumberOfPages; page++)
                {
                    string img = LoadImage(pdfPath, page, context);
                    db.BookSlides.Add(new BookSlide {
                        img = img, bookId = row.id, OrderIndex = iorder
                    });
                    iorder++;
                }
                break;
            }
            db.SaveChanges();
            context.Response.Write("success");
        }
Example #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int                     uniteId   = int.Parse(context.Request["pageId"]);
            HttpPostedFile          uniteFile = context.Request.Files["uniteFile"];
            BrandsMktgBooksEntities db        = new BrandsMktgBooksEntities();

            string game_file = "";

            if (uniteFile.ContentLength > 0)
            {
                string sfiletype = uniteFile.FileName;
                sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower();
                game_file = uniteFile.FileName.Replace(".zip", "");
                string        _path = context.Server.MapPath("~/Media/Unites/" + uniteId + "/");
                DirectoryInfo dir   = new DirectoryInfo(_path);

                if (!dir.Exists)
                {
                    dir.Create();
                }
                string filepath = _path + game_file + "." + sfiletype;
                uniteFile.SaveAs(filepath);
                FileInfo fi = new FileInfo(filepath);
                Decompress(filepath);
                fi.Delete();
            }
            db.BookUniteFiles.Add(new BookUniteFile {
                InteractiveFile = game_file, uniteId = uniteId
            });
            db.SaveChanges();
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = int.Parse(context.Request["id"]);

            string[] collection        = context.Request["collec"].Split('!');
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            var group    = db.cms_groups.Where(x => x.id == id).SingleOrDefault();
            var policies = db.cms_policies.Where(x => x.groupId == id).ToList();

            foreach (cms_policies pol in policies)
            {
                db.cms_policies.Remove(pol);
            }
            foreach (string val in collection)
            {
                if (val != "")
                {
                    string[] vals = val.Split('|');

                    db.cms_policies.Add(new cms_policies()
                    {
                        permissionId = int.Parse(vals[1]), groupId = id, event_permitted = vals[0]
                    });
                }
            }
            db.SaveChanges();
            context.Response.Write("success");
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int opId = int.Parse(Request["opId"]);

            int.TryParse(Request["page"], out page);
            bool perm = Permissions.Check(opId, "Schools", "view");

            levels    = db.BooksLevels.ToList();
            searchKey = Request["key"];
            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                var allresults = db.Schools.OrderByDescending(x => x.id).ToList();
                if (!string.IsNullOrEmpty(searchKey))
                {
                    allresults = allresults.Where(x => x.title.ToLower().Contains(searchKey) || x.artitle.ToLower().Contains(searchKey)).ToList();
                }
                resultCount = allresults.Count;
                PageCount   = resultCount / pageSize;
                if (allresults.Count % pageSize > 0)
                {
                    PageCount += 1;
                }
                if (page < 1 || page > PageCount)
                {
                    page = 1;
                }
                results = allresults.Skip((page - 1) * pageSize)
                          .Take(pageSize).ToList();
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "CMS Users", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                users  = db.cms_user.ToList();
                groups = db.cms_groups.ToList();
                selectgroup.DataSource     = groups;
                selectgroup.DataTextField  = "name";
                selectgroup.DataValueField = "id";
                selectgroup.DataBind();
                foreach (cms_groups group in groups)
                {
                    groupsList += ",{ value: " + group.id + ", text: '" + group.name + "' }";
                }
                if (groupsList.Length > 0)
                {
                    groupsList = groupsList.Substring(1);
                }
            }
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "CMS Users", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
                contentList = db.Contents.ToList();
                if (contentList.Count() > 0)
                {
                    row                       = contentList.FirstOrDefault();
                    AboutUs.Value             = row.AboutUs;
                    Description.Value         = row.Description;
                    Keywords.Value            = row.keywords;
                    Email.Value               = row.Email;
                    AddressLine.Value         = row.AddressLine;
                    Phone.Value               = row.Phone;
                    Fax.Value                 = row.Fax;
                    Longitude.Value           = row.longitude.ToString();
                    Latitude.Value            = row.latitude.ToString();
                    SmtpServer.Value          = row.SmtpServer;
                    SmtpPort.Value            = row.SmtpPort;
                    IsSSL.Checked             = row.IsSSL != null ? (bool)row.IsSSL : false;
                    SystemEmail.Value         = row.SystemEmail;
                    SystemEmailPassword.Value = row.SystemEmailPassword;
                    InfoEmail.Value           = row.InfoEmail;
                    SmartLearningVideo.Value  = row.SmartLearningVideo;
                }
            }
        }
Example #10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BrandsMktgBooksEntities db        = new BrandsMktgBooksEntities();
            HttpPostedFile          codesfile = context.Request.Files["studentsfile"];
            int levelId  = int.Parse(context.Request["levelsSelect"]);
            int schoolId = int.Parse(context.Request["pageId"]);

            if (codesfile.ContentLength > 0)
            {
                string sfiletype = codesfile.FileName;
                sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower();
                string codes_file = Guid.NewGuid().ToString() + "." + sfiletype;
                string _path      = context.Server.MapPath("~/Media");
                codesfile.SaveAs(_path + "/" + codes_file);
                IEnumerable <ExcelStudent> students = ReadInData.GetDataReg(_path + "/" + codes_file, "Sheet1");
                foreach (var row in students)
                {
                    string accessCode = Get8Digits();
                    var    student    = db.Students.Add(new Student {
                        AccessCode = accessCode, Address = row.Address, Email = row.Email, FirstName = row.FirstName, LastName = row.LastName, Phone = row.Phone, schoolId = schoolId, levelId = levelId
                    });
                }
            }
            db.SaveChanges();
            context.Response.Write("Success");
        }
Example #11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int                     bookId    = int.Parse(context.Request["pageId"]);
            HttpPostedFile          thumbfile = context.Request.Files["Thumb"];
            HttpPostedFile          pdffile   = context.Request.Files["pdf"];
            HttpPostedFile          gamefile  = context.Request.Files["GameFile"];
            BrandsMktgBooksEntities db        = new BrandsMktgBooksEntities();
            string                  title     = context.Request["title"];
            string                  pdf_file  = "";

            if (pdffile.ContentLength > 0)
            {
                string sfiletype = pdffile.FileName;
                sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower();
                pdf_file  = Guid.NewGuid().ToString() + "." + sfiletype;
                string _path = context.Server.MapPath("~/Media");
                pdffile.SaveAs(_path + "/" + pdf_file);
            }
            string thumb_file = "";

            if (thumbfile.ContentLength > 0)
            {
                string sfiletype = thumbfile.FileName;
                sfiletype  = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower();
                thumb_file = Guid.NewGuid().ToString() + "." + sfiletype;
                string _path = context.Server.MapPath("~/Media");
                thumbfile.SaveAs(_path + "/" + thumb_file);
            }
            string game_file = "";

            if (gamefile.ContentLength > 0)
            {
                string sfiletype = gamefile.FileName;
                sfiletype = sfiletype.Substring(sfiletype.LastIndexOf('.') + 1).ToLower();
                game_file = gamefile.FileName.Replace(".zip", "");
                string        _path = context.Server.MapPath("~/Media/Stories/" + bookId + "/");
                DirectoryInfo dir   = new DirectoryInfo(_path);

                if (!dir.Exists)
                {
                    dir.Create();
                }
                string filepath = _path + game_file + "." + sfiletype;
                gamefile.SaveAs(filepath);
                FileInfo fi = new FileInfo(filepath);
                Decompress(filepath);
                fi.Delete();
            }
            db.BookStories.Add(new BookStory {
                InteractiveFile = game_file, bookId = bookId, thumb = thumb_file, title = title, pdf = pdf_file
            });
            db.SaveChanges();
        }
Example #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int opId = int.Parse(Request["opId"]);

            int.TryParse(Request["page"], out page);
            pageId = int.Parse(Request["pageId"]);
            bool perm = Permissions.Check(opId, "Web Users", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                school    = db.Schools.Where(x => x.id == pageId).SingleOrDefault();
                searchKey = Request["key"];
                var allresults = db.Students.Where(x => x.schoolId == pageId).OrderByDescending(x => x.id).ToList();
                if (!string.IsNullOrEmpty(searchKey))
                {
                    allresults = allresults.Where(x => x.Address.Contains(searchKey) || (x.School != null ? x.School.title.Contains(searchKey) : false) || x.Email.Contains(searchKey) || x.FirstName.Contains(searchKey) || x.LastName.Contains(searchKey) || x.Phone.Contains(searchKey)).ToList();
                }
                resultCount = allresults.Count;
                PageCount   = resultCount / pageSize;
                if (allresults.Count % pageSize > 0)
                {
                    PageCount += 1;
                }
                if (page < 1 || page > PageCount)
                {
                    page = 1;
                }
                results = allresults.Skip((page - 1) * pageSize)
                          .Take(pageSize).OrderByDescending(x => x.id).ToList();
                var levels = db.BooksLevels.ToList();
                levelsSelect.DataSource     = levels;
                levelsSelect.DataTextField  = "title";
                levelsSelect.DataValueField = "id";
                levelsSelect.DataBind();
                levelsSelect.Items.Insert(0, new ListItem("Select Level", "-1"));
                foreach (BooksLevel level in levels)
                {
                    levelsList += ",{ value: " + level.id + ", text: '" + level.title + "' }";
                }
                if (levelsList.Length > 0)
                {
                    levelsList = levelsList.Substring(1);
                }
            }
        }
Example #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            Content content            = new Content();
            var     contentList        = db.Contents;

            if (contentList.Count() > 0)
            {
                content                     = contentList.FirstOrDefault();
                content.AboutUs             = context.Request["AboutUs"];
                content.Description         = context.Request["Description"];
                content.keywords            = context.Request["Keywords"];
                content.Email               = context.Request["Email"];
                content.AddressLine         = context.Request["AddressLine"];
                content.Phone               = context.Request["Phone"];
                content.Fax                 = context.Request["Fax"];
                content.longitude           = context.Request["Longitude"];
                content.latitude            = context.Request["Latitude"];
                content.SmtpServer          = context.Request["SmtpServer"];
                content.SmtpPort            = context.Request["SmtpPort"];
                content.IsSSL               = context.Request["IsSSL"] == "on";
                content.SystemEmail         = context.Request["SystemEmail"];
                content.SystemEmailPassword = context.Request["SystemEmailPassword"];
                content.InfoEmail           = context.Request["InfoEmail"];
                content.SmartLearningVideo  = context.Request["SmartLearningVideo"];
            }
            else
            {
                content.AboutUs             = context.Request["AboutUs"];
                content.Description         = context.Request["Description"];
                content.keywords            = context.Request["Keywords"];
                content.Email               = context.Request["Email"];
                content.AddressLine         = context.Request["AddressLine"];
                content.Phone               = context.Request["Phone"];
                content.Fax                 = context.Request["Fax"];
                content.longitude           = context.Request["Longitude"];
                content.latitude            = context.Request["Latitude"];
                content.SmtpServer          = context.Request["SmtpServer"];
                content.SmtpPort            = context.Request["SmtpPort"];
                content.IsSSL               = context.Request["IsSSL"] == "on";
                content.SystemEmail         = context.Request["SystemEmail"];
                content.SystemEmailPassword = context.Request["SystemEmailPassword"];
                content.InfoEmail           = context.Request["InfoEmail"];
                content.SmartLearningVideo  = context.Request["SmartLearningVideo"];
                db.Contents.Add(content);
            }
            db.SaveChanges();
            context.Response.Write("success");
        }
Example #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "Books", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                results = db.BooksLevels.ToList().OrderBy(x => x.OrderIndex).ToList();
            }
        }
Example #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "CMS Groups", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                groups      = db.cms_groups.ToList();
                permissions = db.cms_permissions.ToList();
            }
        }
Example #16
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int imId = int.Parse(context.Request["id"]);
            var row  = db.Schools.Where(x => x.id == imId).SingleOrDefault();

            switch (context.Request["field"])
            {
            case "thumb":
                row.thumb = SaveImage(context, context.Request["img"]);
                break;
            }
            db.SaveChanges();
            context.Response.Write("success");
        }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId   = int.Parse(Request["opId"]);
            int  bookId = int.Parse(Request["pageId"]);
            bool perm   = Permissions.Check(opId, "Books", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                results = db.BookStories.Where(x => x.bookId == bookId).ToList();
                book    = db.Books.Where(x => x.id == bookId).SingleOrDefault();
            }
        }
Example #18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int imId = int.Parse(context.Request["id"]);
            var row  = db.BookPosters.Where(x => x.id == imId).SingleOrDefault();

            switch (context.Request["field"])
            {
            case "Img":
                row.thumb = SaveImage(context, context.Request["img"]);
                break;

            case "interactive":
                string filename = row.InteractiveFile;
                row.InteractiveFile = SaveZip(context, context.Request["img"], filename, row.bookId);
                break;
            }
            db.SaveChanges();
            context.Response.Write("success");
        }
Example #19
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpPostedFile thumb = context.Request.Files["thumb"];
            HttpPostedFile Pdffile = context.Request.Files["pdf"];
            string         thumb_file = "", pdf_file = "";

            if (thumb.ContentLength > 0)
            {
                string sfiletype1 = thumb.FileName;
                sfiletype1 = sfiletype1.Substring(sfiletype1.LastIndexOf('.') + 1).ToLower();
                thumb_file = Guid.NewGuid().ToString() + "." + sfiletype1;
                string _path1 = context.Server.MapPath("~/Media");
                thumb.SaveAs(_path1 + "/" + thumb_file);
            }
            if (Pdffile.ContentLength > 0)
            {
                string sfiletype1 = Pdffile.FileName;
                sfiletype1 = sfiletype1.Substring(sfiletype1.LastIndexOf('.') + 1).ToLower();
                pdf_file   = Guid.NewGuid().ToString() + "." + sfiletype1;
                string _path1 = context.Server.MapPath("~/Media");
                Pdffile.SaveAs(_path1 + "/" + pdf_file);
            }
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            string title        = context.Request["title"];
            string lang         = context.Request["langselect"];
            bool   isAvailable  = context.Request["isAvailable"] == "on";
            int    levelId      = int.Parse(context.Request["levelselect"]);
            int    categoryId   = int.Parse(context.Request["categoryselect"]);
            bool   isSingleBook = context.Request["isSingleBook"] == "on";
            string VimeoId      = context.Request["VimeoId"];
            Book   book         = new Book {
                title = title, thumb = thumb_file, pdf = pdf_file, isAvailable = isAvailable, lang = lang, levelId = levelId, categoryId = categoryId, isSingleBook = isSingleBook, VimeoId = VimeoId
            };

            book = db.Books.Add(book);

            db.SaveChanges();
        }
Example #20
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int           sId          = int.Parse(context.Request["sId"]);
            var           result       = db.Students.Where(x => x.schoolId == sId).ToList();
            var           school       = db.Schools.Where(x => x.id == sId).SingleOrDefault();
            StringBuilder sb           = new StringBuilder();

            sb.Append("FirstName\tLastName\tEmail \t Phone\t Address\t Accesscode\r\n");
            foreach (var row in result)
            {
                sb.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\r\n", row.FirstName, row.LastName, row.Email, row.Phone, row.Address, row.AccessCode);
            }
            context.Response.Buffer  = true;
            context.Response.Charset = "";
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.ContentType = "application/vnd.ms-exce";
            context.Response.AddHeader("content-disposition", "attachment;filename=" + school.title.Replace(" ", "-") + "-students.xls");
            context.Response.Write(sb.ToString());
            context.Response.Flush();
            context.Response.End();
            context.Response.Write("Hello World");
        }
Example #21
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int    id           = int.Parse(context.Request["id"]);
            int    toPosition   = int.Parse(context.Request["toPosition"]);
            int    fromPosition = int.Parse(context.Request["fromPosition"]);
            string direction    = context.Request["direction"];
            string table        = context.Request["table"];

            switch (table)
            {
            case "Levels":
                if (direction == "back")
                {
                    var moved = db.BooksLevels.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex++;
                    }
                }
                else
                {
                    var moved = db.BooksLevels.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex--;
                        if (p.OrderIndex < 0)
                        {
                            p.OrderIndex = 0;
                        }
                    }
                }
                db.BooksLevels.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition;
                break;

            case "Categories":
                if (direction == "back")
                {
                    var moved = db.Categories.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex++;
                    }
                }
                else
                {
                    var moved = db.Categories.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex--;
                        if (p.OrderIndex < 0)
                        {
                            p.OrderIndex = 0;
                        }
                    }
                }
                db.Categories.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition;
                break;

            case "Slides":
                if (direction == "back")
                {
                    var moved = db.BookSlides.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex++;
                    }
                }
                else
                {
                    var moved = db.BookSlides.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex--;
                        if (p.OrderIndex < 0)
                        {
                            p.OrderIndex = 0;
                        }
                    }
                }
                db.BookSlides.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition;
                break;

            case "BookUnites":
                if (direction == "back")
                {
                    var moved = db.BookUnites.Where(c => (toPosition <= c.OrderIndex && c.OrderIndex <= fromPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex++;
                    }
                }
                else
                {
                    var moved = db.BookUnites.Where(c => (fromPosition <= c.OrderIndex && c.OrderIndex <= toPosition))
                                .ToList();
                    foreach (var p in moved)
                    {
                        p.OrderIndex--;
                        if (p.OrderIndex < 0)
                        {
                            p.OrderIndex = 0;
                        }
                    }
                }
                db.BookUnites.Where(x => x.id == id).SingleOrDefault().OrderIndex = toPosition;
                break;
            }
            db.SaveChanges();
            context.Response.Write("success");
        }
Example #22
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string table               = context.Request.Form["table"];
            string ips                 = context.Request.Form["ips"];
            int    tableId             = int.Parse(context.Request.Form["tableId"]);
            string key                 = context.Request["key"];
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            string success             = "";

            switch (table)
            {
            case "cms_user":
                cms_user user = db.cms_user.Where(x => x.id == tableId).SingleOrDefault();
                db.cms_user.Remove(user);
                success = "success";
                break;

            case "cms_groups":
                cms_groups group = db.cms_groups.Where(x => x.id == tableId).SingleOrDefault();
                db.cms_groups.Remove(group);
                success = "success";
                break;

            case "Slides":
                BookSlide slide = db.BookSlides.Where(x => x.id == tableId).SingleOrDefault();
                db.BookSlides.Remove(slide);
                success = "success";
                try
                {
                    File.Delete(context.Server.MapPath("~/Media/" + slide.img));
                }
                catch { }
                break;

            case "BookUnites":
                BookUnite bunite = db.BookUnites.Where(x => x.id == tableId).SingleOrDefault();
                db.BookUnites.Remove(bunite);
                success = "success";
                break;

            case "BookUniteFiles":
                BookUniteFile unitefile = db.BookUniteFiles.Where(x => x.id == tableId).SingleOrDefault();
                db.BookUniteFiles.Remove(unitefile);
                success = "success";
                break;

            case "Books":
                Book b = db.Books.Where(x => x.id == tableId).SingleOrDefault();
                db.Books.Remove(b);
                success = "success";
                try
                {
                    File.Delete(context.Server.MapPath("~/Media/" + b.thumb));
                    File.Delete(context.Server.MapPath("~/Media/" + b.pdf));
                }
                catch { }
                break;

            case "Levels":
                BooksLevel level = db.BooksLevels.Where(x => x.id == tableId).SingleOrDefault();
                db.BooksLevels.Remove(level);
                success = "success";
                break;

            case "BooksCategories":
                Category cat = db.Categories.Where(x => x.id == tableId).SingleOrDefault();
                db.Categories.Remove(cat);
                success = "success";
                break;

            case "Schools":
                School school = db.Schools.Where(x => x.id == tableId).SingleOrDefault();
                db.Schools.Remove(school);
                success = "success";
                try
                {
                    File.Delete(context.Server.MapPath("~/Media/" + school.thumb));
                }
                catch { }
                break;

            case "Posters":
                BookPoster game = db.BookPosters.Where(x => x.id == tableId).SingleOrDefault();
                db.BookPosters.Remove(game);
                try
                {
                    Directory.Delete(context.Server.MapPath("~/Media/Games/" + game.bookId + "/" + game.InteractiveFile));
                    File.Delete(context.Server.MapPath("~/Media/" + game.thumb));
                }
                catch { }
                success = "success";
                break;

            case "Stories":
                BookStory story = db.BookStories.Where(x => x.id == tableId).SingleOrDefault();
                db.BookStories.Remove(story);
                try
                {
                    Directory.Delete(context.Server.MapPath("~/Media/Games/" + story.bookId + "/" + story.InteractiveFile));
                    File.Delete(context.Server.MapPath("~/Media/" + story.thumb));
                    File.Delete(context.Server.MapPath("~/Media/" + story.pdf));
                }
                catch { }
                success = "success";
                break;

            case "IPs":
                AllowIP(ips);
                break;

            case "Sessions":
                SessionUser.Remove(key);
                break;
            }
            db.SaveChanges();
            context.Response.Write(success);
        }
Example #23
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string name    = context.Request.Form["name"];
            string value   = context.Request.Form["value"];
            int    pk      = int.Parse(context.Request.Form["pk"]);
            string success = "";
            string table   = context.Request.QueryString["table"];

            if (table == null)
            {
                table = context.Request.Form["table"];
            }
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();

            switch (table)
            {
            case "cms_user":
                var user = db.cms_user.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("username"))
                {
                    user.username = value;
                }
                else if (name.Contains("cmsgroup"))
                {
                    user.groupId = int.Parse(value);
                }
                else if (name.Contains("status"))
                {
                    user.status = int.Parse(value);
                }
                else if (name.Contains("password"))
                {
                    user.password = MD5Hash(value);
                }
                else if (name.Contains("firstname"))
                {
                    user.firstname = value;
                }
                else if (name.Contains("lastname"))
                {
                    user.lastname = value;
                }
                else if (name.Contains("email"))
                {
                    user.email = value;
                }
                else if (name.Contains("phone"))
                {
                    user.phone = value;
                }
                else if (name.Contains("address"))
                {
                    user.address = value;
                }
                success = "success";
                break;

            case "cms_groups":
                var group = db.cms_groups.Where(x => x.id == pk).SingleOrDefault();
                group.name = value;
                success    = "success";
                break;

            case "Books":
                var project = db.Books.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("title"))
                {
                    project.title = value;
                }
                else if (name.Contains("lang"))
                {
                    project.lang = value;
                }
                if (name.Contains("level"))
                {
                    project.levelId = int.Parse(value);
                }
                else if (name.Contains("isAvailable"))
                {
                    project.isAvailable = value == "YES";
                }
                else if (name.Contains("isSingleBook"))
                {
                    project.isSingleBook = value == "YES";
                }
                if (name.Contains("VimeoId"))
                {
                    project.VimeoId = value;
                }
                success = "success";
                break;

            case "BookUnites":
                var unite = db.BookUnites.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("title"))
                {
                    unite.title = value;
                }
                success = "success";
                break;

            case "Posters":
                var poster = db.BookPosters.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("title"))
                {
                    poster.title = value;
                }
                break;

            case "Stories":
                var story = db.BookStories.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("title"))
                {
                    story.title = value;
                }
                break;

            case "Levels":
                var level = db.BooksLevels.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("title"))
                {
                    level.title = value;
                }
                if (name.Contains("lang"))
                {
                    level.lang = value;
                }
                success = "success";
                break;

            case "BooksCategories":
                var cat = db.Categories.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("title"))
                {
                    cat.title = value;
                }
                success = "success";
                break;

            case "Schools":
                var school = db.Schools.Where(x => x.id == pk).SingleOrDefault();
                if (name.Contains("artitle"))
                {
                    school.artitle = value;
                }
                if (name.Contains("entitle"))
                {
                    school.title = value;
                }
                if (name.Contains("showGame"))
                {
                    school.showGame = value == "YES";
                }
                success = "success";
                break;

            case "Students":
                var student = db.Students.Where(x => x.id == pk).SingleOrDefault();
                student.levelId = int.Parse(value);
                break;
            }
            db.SaveChanges();
            context.Response.Write(success);
        }
Example #24
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string table = context.Request.Form["table"];
            string Rows  = context.Request.Form["Rows"];

            string[] split             = Rows.Split('|');
            string   success           = "";
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int lastOrderId            = 1;

            switch (table)
            {
            case "cms_user":
                db.cms_user.Add(new cms_user()
                {
                    username = split[0], password = MD5Hash(split[1]), groupId = int.Parse(split[2]), status = int.Parse(split[3]), firstname = split[4], lastname = split[5], phone = split[6], email = split[7], address = split[8]
                });
                success = "success";
                break;

            case "cms_groups":
                db.cms_groups.Add(new cms_groups()
                {
                    name = split[0]
                });
                success = "success";
                break;

            case "Levels":
                var orderId = db.BooksLevels.OrderByDescending(x => x.OrderIndex).FirstOrDefault();

                if (orderId != null)
                {
                    lastOrderId = (int)orderId.OrderIndex + 1;
                }
                db.BooksLevels.Add(new BooksLevel()
                {
                    title = split[0], lang = split[1], OrderIndex = lastOrderId
                });
                success = "success";
                break;

            case "BooksCategories":
                var catorderId = db.Categories.OrderByDescending(x => x.OrderIndex).FirstOrDefault();

                if (catorderId != null)
                {
                    lastOrderId = (int)catorderId.OrderIndex + 1;
                }
                db.Categories.Add(new Category()
                {
                    title = split[0], OrderIndex = lastOrderId
                });
                success = "success";
                break;

            case "BookUnites":
                var lastunite = db.BookUnites.OrderByDescending(x => x.OrderIndex).FirstOrDefault();

                if (lastunite != null)
                {
                    lastOrderId = (int)lastunite.OrderIndex + 1;
                }
                db.BookUnites.Add(new BookUnite {
                    title = split[0], bookId = int.Parse(split[1]), OrderIndex = lastOrderId
                });
                break;

            case "IPs":
                string val = split[0];
                BlockIP(val);
                break;
            }

            db.SaveChanges();
            context.Response.Write(success);
        }
Example #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int opId = int.Parse(Request["opId"]);

            int.TryParse(Request["page"], out page);
            bool perm = Permissions.Check(opId, "Books", "view");

            searchKey = !string.IsNullOrEmpty(Request["key"])? Request["key"].ToLower():"";
            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                var allresults = db.Books.OrderByDescending(x => x.id).ToList();
                if (!string.IsNullOrEmpty(searchKey))
                {
                    allresults = allresults.Where(x => x.title.ToLower().Contains(searchKey)).ToList();
                }
                resultCount = allresults.Count;
                PageCount   = resultCount / pageSize;
                if (allresults.Count % pageSize > 0)
                {
                    PageCount += 1;
                }
                if (page < 1 || page > PageCount)
                {
                    page = 1;
                }
                results = allresults.Skip((page - 1) * pageSize)
                          .Take(pageSize).ToList();
                levels = db.BooksLevels.ToList();
                levelselect.DataSource     = levels;
                levelselect.DataTextField  = "title";
                levelselect.DataValueField = "id";
                levelselect.DataBind();
                foreach (BooksLevel level in levels)
                {
                    levelsList += ",{ value: " + level.id + ", text: '" + level.title + "' }";
                }
                if (!string.IsNullOrEmpty(levelsList))
                {
                    levelsList = levelsList.Substring(1);
                }

                var categories = db.Categories.ToList();
                categoryselect.DataSource     = categories;
                categoryselect.DataTextField  = "title";
                categoryselect.DataValueField = "id";
                categoryselect.DataBind();
                foreach (Category category in categories)
                {
                    categoriesList += ",{ value: " + category.id + ", text: '" + category.title + "' }";
                }
                if (!string.IsNullOrEmpty(categoriesList))
                {
                    categoriesList = categoriesList.Substring(1);
                }
            }
        }