예제 #1
0
    protected void btnSubmitProduct_OnClick(object sender, EventArgs e)
    {
        ProductsModel.Product product = new ProductsModel.Product();
        var productImage = imageRepository.ReadImages().FirstOrDefault(i => i.Id == Convert.ToInt32(ddlImages.SelectedValue));

        if (txtTitle.Text != "" && txtPrice.Text != "" && txtComment.Text != "")
        {
            product.Comment = txtComment.Text;
            product.Price   = Convert.ToInt32(txtPrice.Text);
            product.Title   = txtTitle.Text;
            product.Images  = productImage.Id;
            productsRepository.Create(product);
            Response.Redirect("products.aspx");
        }
        else if (txtTitle.Text == "")
        {
            litWarning.Text = Bootstrap.Alert("Please insert a title.", 4);
        }
        else if (txtComment.Text == "")
        {
            litWarning.Text = Bootstrap.Alert("Please insert a description.", 4);
        }
        else if (txtPrice.Text == "")
        {
            litWarning.Text = Bootstrap.Alert("Please choose a price.", 4);
        }
        else
        {
            litWarning.Text = Bootstrap.Alert("Test", 4);
        }
    }
예제 #2
0
    protected void btnEditPage_OnClick(object sender, EventArgs e)
    {
        var id           = Convert.ToInt32(Request.QueryString["Id"]);
        var pageTemplate = pageRepository.ReadPages().FirstOrDefault(p => p.Id == id);

        pageTemplate.Content = Editor1.Content;
        if (Editor1.Content != "" || txtTitle.Text != "")
        {
            pageTemplate.Edited  = DateTime.Now;
            pageTemplate.Creator = "Administrator";
            var pageCategory =
                pageRepository.ReadPageCategory()
                .FirstOrDefault(pc => pc.Id == Convert.ToInt32(ddlCategory.SelectedValue));
            pageTemplate.PageCategories = pageCategory;
            pageTemplate.Title          = txtTitle.Text;
            pageRepository.UpdatePage(pageTemplate);
            litWarning.Text = Bootstrap.Alert("Page Edited", 1);
        }
        else if (Editor1.Content == "")
        {
            litWarning.Text = Bootstrap.Alert("Please insert some content to your page.", 4);
        }
        else if (txtTitle.Text == "")
        {
            litWarning.Text = Bootstrap.Alert("Please insert a title to the page.", 4);
        }
    }
예제 #3
0
    protected void btnCreatePage_OnClick(object sender, EventArgs e)
    {
        PageModel.PageTemplate pageTemplate = new PageModel.PageTemplate();

        if (Editor1.Content != "" || txtTitle.Text != "")
        {
            pageTemplate.Content = Editor1.Content;
            pageTemplate.Created = DateTime.Now;
            pageTemplate.Edited  = DateTime.Now;
            pageTemplate.Creator = "Administrator";
            var pageCategory = pageRepository.ReadPageCategory().FirstOrDefault(pc => pc.Id == Convert.ToInt32(ddlCategory.SelectedValue));
            pageTemplate.PageCategories = pageCategory;
            pageTemplate.Title          = txtTitle.Text;
            pageRepository.CreatePages(pageTemplate);
            Response.Redirect("Pages.aspx");
        }
        else if (Editor1.Content == "")
        {
            litWarning.Text = Bootstrap.Alert("Please insert some content to your page.", 4);
        }
        else if (txtTitle.Text == "")
        {
            litWarning.Text = Bootstrap.Alert("Please insert a title to the page.", 4);
        }
    }
예제 #4
0
 protected void btnSubmitFiles_OnClick(object sender, EventArgs e)
 {
     if (fileUpload.HasFiles || fileUpload.HasFile)
     {
         UploadModel.Upload(fileUpload);
         Response.Redirect(redirectUrl);
     }
     else
     {
         litWarning.Text = Bootstrap.Alert("Please add a file!", 4);
     }
 }
예제 #5
0
파일: Pages.aspx.cs 프로젝트: Dustymcp/Cms
 protected void btnCreateCategory_OnClick(object sender, EventArgs e)
 {
     PageModel.PageCategory pageCategory = new PageModel.PageCategory();
     if (txtCategoryName.Text == "")
     {
         litWarning.Text = Bootstrap.Alert("Please choose a category name.", 4);
     }
     else
     {
         pageCategory.Name = txtCategoryName.Text;
         pageRepository.CreatePageCategory(pageCategory);
         Response.Redirect(Request.RawUrl);
     }
 }
예제 #6
0
    protected void btnSubmitMail_OnClick(object sender, EventArgs e)
    {
        var mail = new ContactModel.Mail
        {
            Sender  = txtSender.Text,
            Title   = txtTitel.Text,
            Watched = false,
            Content = txtContent.Text,
            Created = DateTime.Now
        };

        repo.CreateMail(mail);
        litWarning.Text = Bootstrap.Alert("Thanks for your mail we will get back to you shortly.", 1);
    }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var id    = Convert.ToInt32(Request.QueryString["Id"]);
        var image = uploadRepository.ReadImages().FirstOrDefault(i => i.Id == id);

        if (image != null)
        {
            litImageName.Text = image.Filename;
            litFullImage.Text = Bootstrap.Image(image.Filename, 1500, 1500, "max", true);
        }
        else
        {
            litImageName.Text = Bootstrap.Alert("No image found.", 4);
        }
    }
예제 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var queryId = Convert.ToInt32(Request.QueryString["Id"]);

        var getPage = pageRepository.ReadPages().FirstOrDefault(p => p.Id == queryId);
        var getCat  = pageRepository.ReadPageCategory().FirstOrDefault(p => getPage != null && p.Id == getPage.PageCategories.Id);

        if (getPage != null)
        {
            litTitle.Text    = getPage.Title;
            litCategory.Text = getCat.Name;
            litCreator.Text  = getPage.Creator;
            litContent.Text  = getPage.Content;
            litCreated.Text  = getPage.Created.ToLongDateString() + " : " + getPage.Created.ToLongTimeString();
        }
        else
        {
            litContent.Text = Bootstrap.Alert("Cant find a page.", 4);
        }
    }
예제 #9
0
파일: Movies.aspx.cs 프로젝트: Dustymcp/Cms
    protected void btnSubmitSearch_OnClick(object sender, EventArgs e)
    {
        var searcQuery = movieRepo.ReadActors().Where(a => a.Name.ToLower().StartsWith(txtSearcActor.Text.ToLower()));

        if (txtSearcActor.Text == "")
        {
            litWarning.Text = Bootstrap.Alert("We dont give away free server power here, search on something!", 4);
        }
        else if (searcQuery.Count() <= 0)
        {
            litWarning.Text = Bootstrap.Alert("No Results try the starting letter of the actor.", 4);
        }
        else
        {
            litWarning.Text         = "";
            rptActorList.DataSource = searcQuery;

            rptActorList.DataBind();
        }
    }
예제 #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var repo        = new UploadModel.Repository();
        var productRepo = new ProductsModel.Repository();
        var id          = Convert.ToInt32(Request.QueryString["Id"]);
        var delete      = Convert.ToBoolean(Request.QueryString["Delete"]);

        if (delete)
        {
            var imageToDelete     = repo.ReadImages().FirstOrDefault(i => i.Id == id);
            var productImageCount = productRepo.Read().Count(pi => imageToDelete != null && pi.Images == imageToDelete.Id);
            if (imageToDelete != null)
            {
                if (productImageCount == 0)
                {
                    var fileOnServer = new FileInfo(Server.MapPath(@"~/upload/" + imageToDelete.Filename));
                    repo.DeleteImage(imageToDelete);
                    fileOnServer.Delete();
                    Response.Redirect(redirectUrl);
                }
                else
                {
                    litWarning.Text = Bootstrap.Alert("Please delete products associated with the image.", 4);
                }
            }
            else
            {
                litWarning.Text = Bootstrap.Alert("Error occured, the image does not exist. try refreshing the page.", 4);
            }
        }



        foreach (var image in repo.ReadImages())
        {
            litTableImages.Text += "<tr><td>" + Bootstrap.Image(image.Filename, 200, 200, "crop", true) + "</td><td>" + image.Id + "</td><td>" + image.Filename + "</td><td><a href='images.aspx?id=" + image.Id + "&Delete=true'><span class='glyphicon glyphicon-remove-sign icon-lg'></span></a></td></tr>";
        }
    }
예제 #11
0
파일: Pages.aspx.cs 프로젝트: Dustymcp/Cms
 protected void Page_Load(object sender, EventArgs e)
 {
     foreach (var page in pageRepository.ReadPages())
     {
         litPageOverview.Text += @"<tr><td><a href='Pages.aspx?Id=" + page.Id + "&Delete=true'>Delete</a></td><td> " +
                                 "<a href='PagesSingle.aspx?Id=" + page.Id + "&Edit=true' >Edit</a></td><td>" + page.Title + "</td><td>" + page.PageCategories.Name + "</td><td>" + page.Created.ToLongDateString() + " @ " + page.Created.ToLongTimeString() + "</td><td>" + Bootstrap.ShortenContent(Server.HtmlEncode(page.Content), 50) + "</td></tr>";
     }
     foreach (var category in pageRepository.ReadPageCategory())
     {
         litpagecategoryoverview.Text += "<tr><td><a href='pages.aspx?DeleteCat=True&Id=" + category.Id + "'>Delete</a></td><td>" + category.Name + "</td><td>" + pageRepository.ReadPages().Count(p => p.PageCategories.Id == category.Id) + "</td></tr>";
     }
     if (!IsPostBack)
     {
         var id        = Convert.ToInt32(Request.QueryString["Id"]);
         var delete    = Convert.ToBoolean(Request.QueryString["Delete"]);
         var deleteCat = Convert.ToBoolean(Request.QueryString["DeleteCat"]);
         if (delete)
         {
             var pagetoodel = pageRepository.ReadPages().FirstOrDefault(p => p.Id == id);
             pageRepository.DeletePage(pagetoodel);
             Response.Redirect("Pages.aspx");
         }
         if (deleteCat)
         {
             var pagecattoodel       = pageRepository.ReadPageCategory().FirstOrDefault(pc => pc.Id == id);
             var pageCountInCategory = pageRepository.ReadPages().Count(p => pagecattoodel != null && p.PageCategories.Id == pagecattoodel.Id);
             if (pageCountInCategory == 0)
             {
                 pageRepository.DeletePageCategory(pagecattoodel);
                 Response.Redirect("Pages.aspx");
             }
             else
             {
                 litWarning.Text = Bootstrap.Alert("You need to delete the pages associated with the category first!", 4);
             }
         }
     }
 }
예제 #12
0
 //add new user with hashed password and userlevel. //MAX LEVEL
 protected void btnSubmitUser_Click(object sender, EventArgs e)
 {
     if (txtUserName.Text == "")
     {
         litWarning.Text = Bootstrap.Alert("Fill in Username..", 4);
     }
     else if (txtPassword.Text == "")
     {
         litWarning.Text = Bootstrap.Alert("Fill in Password..", 4);
     }
     else
     {
         UserModel.User user = new UserModel.User();
         user.UserName       = txtUserName.Text;
         user.HashedPassword = UserModel.Encryption(txtPassword.Text);
         user.UserLevel      = Convert.ToInt32(ddlUserLevel.SelectedItem.Value);
         user.FirstName      = txtFirstName.Text;
         user.LastName       = txtLastName.Text;
         user.StreetAdress   = txtStreetAdress.Text;
         user.StreetAdress   = txtStreetnumber.Text;
         Repo.InsertUser(user);
         Response.Redirect(ReturnUrl);
     }
 }
예제 #13
0
    //Add overview with sorting and edit delete functions.
    public void OverView()
    {
        //get querystrings
        int    id         = Convert.ToInt32(Request.QueryString["Id"]);
        bool   deleteUser = Convert.ToBoolean(Request.QueryString["Delete"]);
        bool   editUser   = Convert.ToBoolean(Request.QueryString["Edit"]);
        string sortOrder  = Request.QueryString["sortOrder"];

        Skip = Convert.ToInt32(Request.QueryString["Skip"]);
        Take = Convert.ToInt32(Request.QueryString["Take"]);

        //delete a user
        if (deleteUser)
        {
            UserModel.User deleteuser = Repo.ShowUsers().FirstOrDefault(u => u.Id == id);
            if (deleteuser == null || deleteuser.Id != Convert.ToInt32(Session["Id"]))
            {
                if (Session["Level"] != null && Convert.ToInt32(Session["Level"]) == 1)
                {
                    Repo.DeleteUser(deleteuser);
                    Response.Redirect(ReturnUrl);
                }
                else
                {
                    Response.Redirect("../Login.aspx");
                }
            }
            else
            {
                litWarning.Text = Bootstrap.Alert("Now you would'nt delete yourself now would you?", 4);
            }
        }
        //call in data to edit a user
        if (editUser)
        {
            if (!IsPostBack)
            {
                UserModel.User userToEdit = Repo.ShowUsers().FirstOrDefault(u => u.Id == id);

                pnlPassword.Visible = false;
                if (userToEdit != null)
                {
                    txtUserName.Text           = userToEdit.UserName;
                    txtFirstName.Text          = userToEdit.FirstName;
                    txtLastName.Text           = userToEdit.LastName;
                    txtStreetAdress.Text       = userToEdit.StreetAdress;
                    txtStreetnumber.Text       = userToEdit.StreetNumber.ToString();
                    ddlUserLevel.SelectedValue = userToEdit.UserLevel.ToString();
                }
                btnSubmitUser.Visible = false;
                btnEditUser.Visible   = true;
                btnBack.Visible       = true;
            }
        }


        if (sortOrder == "UserName")
        {
            rpt.DataSource = Repo.ShowUsers().OrderBy(s => s.UserName).Take(Take).Skip(Skip);
            rpt.DataBind();
        }
        else if (sortOrder == "Id")
        {
            rpt.DataSource = Repo.ShowUsers().OrderBy(s => s.Id).Take(Take).Skip(Skip);
            rpt.DataBind();
        }
        else if (sortOrder == "First")
        {
            rpt.DataSource = Repo.ShowUsers().OrderBy(s => s.FirstName).Take(Take).Skip(Skip);
            rpt.DataBind();
        }
        else if (sortOrder == "Last")
        {
            rpt.DataSource = Repo.ShowUsers().OrderBy(s => s.LastName).Take(Take).Skip(Skip);
            rpt.DataBind();
        }
        else if (sortOrder == "Address")
        {
            rpt.DataSource = Repo.ShowUsers().OrderBy(s => s.LastName).Take(Take).Skip(Skip);
            rpt.DataBind();
        }
        else
        {
            rpt.DataSource = Repo.ShowUsers().OrderBy(u => u.Id).Take(Take).Skip(Skip);
            rpt.DataBind();
        }
    }