private void SaveImage()
        {
            ////Delete previous avatar image if any
            //MemberUploads itm = NHibernateHelper.UniqueResult<MemberUploads>(null, "Id", LoggedInUserKey);
            //if (itm != null)
            //    NHibernateHelper.Delete<MemberUploads>(itm);

            foreach (string inputTagName in Request.Files)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[inputTagName];

                if (isImage(file.FileName, true))
                {

                    MemberDetails usr = NHibernateHelper.UniqueResult<MemberDetails>(null, "Id", LoggedInUserKey);

                    int MyfileCount = NHibernateHelper.Count("select a.Id from MemberUploads a where a.Owner.Id=?", LoggedInUserKey,NHibernate.NHibernateUtil.Int32,false);

                    if (MyfileCount > 10)
                    {
                        throw new Exception("Maximum 10 file uploads are allowed per user. To upload more, please remove any of previous uploads.");
                    }

                    if (file.ContentLength > 0)
                    {

                        //TempData["message"] = "Resizing the file '" + file.FileName + "' to avatar Image now.";

                        MemberUploads attch = new MemberUploads();
                        attch.Owner = usr;
                        attch.Attachmt = file.FileName;

                        attch.FileContentT = file.ContentType;
                        //attch.FileSize = file.ContentLength;
                        attch.CreateD = DateTime.Now;
                        attch.FileDetail = Convert(file); //Utilities.CreateAvatar(100, file.InputStream);
                        attch.FileSize = attch.FileDetail.Length;
                        NHibernateHelper.Save<MemberUploads>(attch);
                        //Save the attachment into database according to the paperId, conferenceCode etc
                        //usr.PicId = attch.Id;
                        //NHibernateHelper.Update<MemberDetails>(usr);

                        //string filePath = Path.Combine(@"C:\MyUploadedFiles", Path.GetFileName(file.FileName));
                        //file.SaveAs(filePath);
                    }
                }
                else
                {
                    throw new Exception("Only JPG , BMP , PNG , GIF and TIF files can be uploaded as profile image.");
                }
            }
        }
        private void SaveAvImage()
        {
            ////Delete previous avatar image if any
            //MemberUploads itm = NHibernateHelper.UniqueResult<MemberUploads>(null, "Id", LoggedInUserKey);
            //if (itm != null)
            //    NHibernateHelper.Delete<MemberUploads>(itm);

            foreach (string inputTagName in Request.Files)
            {
                HttpPostedFileBase file = HttpContext.Request.Files[inputTagName];

                if (isImage(file.FileName, true))
                {

                    MemberDetails usr = NHibernateHelper.UniqueResult<MemberDetails>(null, "Id", LoggedInUserKey);

                    ////Delete previous avatar image if any
                    ////Delete previous avatar image if any
                    if ((usr.PicId.HasValue) && (usr.PicId.Value != 0))
                    {
                        MemberUploads itm = NHibernateHelper.UniqueResult<MemberUploads>(null, "Id", usr.PicId.Value);

                        if (itm != null)
                            NHibernateHelper.Delete<MemberUploads>(itm);
                    }

                    if (file.ContentLength > 0)
                    {

                        TempData["message"] = "Resizing the file '" + file.FileName + "' to avatar Image now.";

                        MemberUploads attch = new MemberUploads();
                        attch.Owner = usr;//NHibernateHelper.UniqueResult<MemberDetails>(null,"Id",LoggedInUserKey);
                        attch.Attachmt = file.FileName;

                        attch.FileContentT = file.ContentType;
                        //attch.FileSize = file.ContentLength;
                        attch.CreateD = DateTime.Now;
                        attch.FileDetail = Utilities.CreateAvatar(100, file.InputStream);
                        attch.FileSize = attch.FileDetail.Length;
                        NHibernateHelper.Save<MemberUploads>(attch);
                        //Save the attachment into database according to the paperId, conferenceCode etc
                        usr.PicId = attch.Id;
                        NHibernateHelper.Update<MemberDetails>(usr);

                    }
                }
                else
                {
                    throw new Exception("Only JPG , BMP , PNG , GIF and TIF files can be uploaded as profile image.");
                }
            }
        }