Exemplo n.º 1
0
        /*
         * @author Hermenegildo Lagniton
         * @description: Takes data from admin add movies page
         * Returns true if movie data is saved to database, otherwise returns false.
         * @Date 30/03/14
         * @TargetDate April 9'th
         */
        public bool addMovie(string mTitle, string mCompany, string mDirector, string mEditor)
        {
            var movieTable = db.GetTable <allmovies>();

            int maxIDquery = (int)(from movie in movieTable select movie.Id).Max() + 1;

            var newMovie = new allmovies
            {
                Id       = maxIDquery,
                Title    = mTitle,
                Company  = mCompany,
                Director = mDirector,
                Editor   = mEditor
            };

            movieTable.InsertOnSubmit(newMovie);

            try
            {
                db.SubmitChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string      movieId = HttpContext.Current.Request.QueryString["id"];
        Model       model   = new Model();
        allmovies   movie   = model.getMovieById(Convert.ToInt32(movieId));
        List <cast> casts   = model.getCharactersById(Convert.ToInt32(movieId));

        if (movie != null)
        {
            movieIdText.InnerText   = movie.Id.ToString();
            titleText.InnerText    += " " + movie.Title;
            directorText.InnerText += " " + movie.Director;
            editorText.InnerText   += " " + movie.Editor;
            companyText.InnerText  += " " + movie.Company;
            titleText2.InnerText   += " " + movie.Title;
            titleText3.InnerText   += " " + movie.Title;
            movieTitle.Text         = movie.Title;
            foreach (cast cast in casts)
            {
                actorText.InnerHtml += "<br> " + cast.castname;
            }
        }
        else
        {
            HttpCookie objCookie;
            objCookie = new HttpCookie("ERROR");
            DateTime now;
            now = DateTime.Now;

            objCookie.Values.Add("message", "Invalid Movie.");
            objCookie.Values.Add("time", now.ToString());

            Response.Cookies.Add(objCookie);
            Response.Redirect("error.aspx");
        }
        // Check if the user is logged in or not
        HttpCookie userInformationCookie = Request.Cookies["userInformation"];

        /*********************
        * *******************
        *  User is not logged in
        * *******************
        *********************/
        if (userInformationCookie == null)
        {
            registerButton.Visible = true;
        }

        /*********************
        * *******************
        *  User is logged in
        * *******************
        *********************/
        else
        {
            btnAddToCart.Visible = true;
        }
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Model      model      = new Model();
        string     cookies    = "";
        string     htmlResult = "";
        HttpCookie objCookie  = Request.Cookies["cartInformation"];

        string deleteItem = HttpContext.Current.Request.QueryString["delete"];

        if (deleteItem != null)
        {
            deleteItemInCart(Convert.ToInt32(deleteItem));
        }


        // No cart so send them an error
        if (objCookie == null)
        {
            HttpCookie errorCookie;
            errorCookie = new HttpCookie("ERROR");
            DateTime now;
            now = DateTime.Now;

            errorCookie.Values.Add("message", "You don't have anything from your cart.");
            errorCookie.Values.Add("time", now.ToString());

            Response.Cookies.Add(errorCookie);
            Response.Redirect("error.aspx");
        }

        cookies += objCookie.Values.ToString();
        string[] delims = { "=&", "=" };

        string[] results = cookies.Split(delims, StringSplitOptions.RemoveEmptyEntries);

        int counter = 1;

        foreach (string result in results)
        {
            allmovies movie = model.getMovieById(Convert.ToInt32(result));

            Random rand          = new Random((int)DateTime.Now.Ticks);
            var    numIterations = rand.Next(100, 500); // GET RANDOM NUMBER
            htmlResult += "<tr><td>" + counter + "</td><td>" + movie.Title + "</td><td>$" + numIterations.ToString() + "</td><td><a href=\"?delete=" + (counter - 1) + "\"><span class=\"glyphicon glyphicon-remove\"></span></a></td></tr>";
            counter++;
            // <tr><td>45</td><td>2.45%</td><td>$100</td><td><span class="glyphicon glyphicon-remove"></span></td></tr>
        }

        tableOrder.InnerHtml = htmlResult;
    }