/*
     * System.Configuration.Configuration rootWebConfig =
     *          System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot");
     *      System.Configuration.ConnectionStringSettings connString;
     *      if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
     *      {
     *          connString =rootWebConfig.ConnectionStrings.ConnectionStrings["NorthwindConnectionString"];
     *          if (connString != null)
     *              Console.WriteLine("Northwind connection string = \"{0}\"",
     *                  connString.ConnectionString);
     *          else
     *              Console.WriteLine("No Northwind connection string");
     *      }
     *
     *
     */


    /*
     *
     * public static List<string> getBlogEntry()
     * {
     *  List<string> str;
     *
     *  var blog = new BlogEntities();
     *
     *  try
     *  {
     *
     *   str = (from p in blog.posts
     *            select p.content).ToList();
     *
     *
     *           string currentLabel = from s2f in stream2FieldTypesTable
     *                where s2f.s2fID == item.s2fID
     *                select s2f.s2fLabel.ToString();
     *
     *
     *
     *
     *  }
     *  //catch (Exception)
     *  //{
     *  //    if (blog.Connection.State == System.Data.ConnectionState.Open)
     *  //    {
     *  //        blog.Dispose();
     *  //    }
     *  //}
     *  ////        try
     *  //        {
     *  //            var theAlbum = context.Albums.Where(i => i.album_id == ID).First();
     *  //        }
     *  //        catch (Exception)
     *  //        {
     *
     *  //            if (context.Connection.state == System.Data.ConnectionState.Open)
     *  //            {
     *  //                context.Dispose();
     *  //            }
     *
     *  //            throw new IdentityMustBeUnique();
     *  //        }
     *  //        finally
     *  //        {
     *  //            if (context.Connection.state == System.Data.ConnectionState.Open)
     *  //            {
     *  //                context.Dispose();
     *
     *  //            }
     *
     *
     *  //        }
     *
     * //     return str;
     *
     *
     * //}
     */

    #endregion


    /*************************************************************
     *  @type: file upload
     *  @usage: this will be used on the next stage of my project
     *  @return: returns true if everything is successful
     *
     **************************************************************/

    public bool Upload(FileUpload fu)
    {
        bool rtn = false;

        try
        {
            if (fu.PostedFile != null && fu.PostedFile.FileName != string.Empty)
            {
                using (BlogEntities be = new BlogEntities())
                {
                    byte[] blob = new byte[fu.PostedFile.ContentLength];
                    Stream fill = fu.FileContent;
                    fill.Read(blob, 0, fu.PostedFile.ContentLength);
                    be.AddTobinaries(binary.Createbinary(DateTime.Now, fu.FileName, blob, fu.PostedFile.ContentType, be.binaries.Max(i => i.binID) + 1));
                    be.SaveChanges();
                }

                rtn = true;
            }
        }
        catch
        {
            throw new UnableToAddObject();
        }


        return(rtn);
    }