public void SortTestWithName()
        {
            ImageDal dal = new ImageDal();

            ImageDetails idetails = new ImageDetails();
            idetails.Name = "Lighthouse.jpg";
            idetails.Image = new byte[] { };
            idetails.Size = 100;

            dal.AddImage(idetails);

             ImageDetails idetails1 = new ImageDetails();
            idetails.Name = "Desert.jpg";
            idetails.Image = new byte[] { };
            idetails.Size = 100;

            dal.AddImage(idetails);

            int index1 = dal.Sort(1).FindLastIndex(x => x.Name == "Lighthouse.jpg");
            int index2 = dal.Sort(1).FindLastIndex(x => x.Name == "Desert.jpg");

            Assert.IsTrue(index1 > index2);

            



        }
        public void RemoveDuplicateTest()
        {
            ImageDal dal = new ImageDal();

            ImageDetails idetails = new ImageDetails();
            idetails.Name = "Lighthouse.jpg";
            idetails.Image = new byte[] { };
            idetails.Size = 100;

            dal.AddImage(idetails);
            dal.AddImage(idetails);

            dal.RemoveDuplicates();

            List<ImageDetails> result = dal.GetAllImages().FindAll(x => x.Name == "Lighthouse.jpg");

            Assert.AreEqual(1, result.Count);


        }
        protected void Upload_Click(object sender, EventArgs e)
        {

            try
            {

                if (FileUpload1.HasFile)
                {
                    ImageDetails iDetails = new ImageDetails();
                    iDetails.Name = FileUpload1.FileName;

                    File.WriteAllBytes(filepath, FileUpload1.FileBytes);

                    FileUpload1.SaveAs(filepath + FileUpload1.FileName);


                    FileInfo fInfo = new FileInfo(filepath);

                    long numBytes = fInfo.Length;

                    //Open FileStream to read file
                    FileStream fStream = new FileStream(filepath, FileMode.Open, FileAccess.Read);

                    //Use BinaryReader to read file stream into byte array.
                    BinaryReader br = new BinaryReader(fStream);

                    //storing byte information in Image field
                    iDetails.Image = br.ReadBytes((int)numBytes);

                    iDetails.Size = numBytes;

                    ImageDal dal = new ImageDal();

                    dal.AddImage(iDetails);

                    ListView1.DataSource = dal.GetAllImages();
                    ListView1.DataBind();


                }
            }
            catch (Exception ex)
            {
                ImageException exception = new ImageException(ex.Message);

            }

        }