public object AddUpdateAlbumPhoto(string photoId, string desc, string albumId, string groupId, string createdBy)
        {
            dynamic LoadImageResult;

            try
            {
                var    httpRequest = HttpContext.Current.Request;
                string FileName    = string.Empty;

                if (httpRequest.Files.Count > 0)
                {
                    bool flag = false;
                    FileName = DateTime.Now.ToString("ddMMyyyyhhmmsstt") + ".png";

                    string Path     = ConfigurationManager.AppSettings["imgPathSave"] + "Documents\\gallery\\Group" + groupId + "\\Album" + albumId;
                    string filePath = ConfigurationManager.AppSettings["imgPathSave"] + "Documents\\gallery\\Group" + groupId + "\\Album" + albumId + "\\" + FileName;

                    foreach (string file in httpRequest.Files)
                    {
                        var postedFile = httpRequest.Files[file];

                        if (!Directory.Exists(Path))
                        {
                            Directory.CreateDirectory(Path);
                        }

                        postedFile.SaveAs(filePath);
                        flag = true;
                    }

                    if (flag)
                    {
                        Gallery.AddUpdateAlbumPhoto(photoId, FileName, desc, albumId, createdBy);
                        LoadImageResult = new { status = "0", message = "success" };
                    }
                    else
                    {
                        LoadImageResult = new { status = "1", message = "failed" };
                    }
                }
                else
                {
                    Gallery.AddUpdateAlbumPhoto(photoId, FileName, desc, albumId, createdBy);
                    LoadImageResult = new { status = "0", message = "success" };
                }
            }
            catch
            {
                LoadImageResult = new { status = "1", message = "failed" };
            }

            return(new { LoadImageResult });
        }
        public object AddUpdateAlbumPhoto(string photoId, string desc, string albumId, string groupId, string createdBy)
        {
            dynamic LoadImageResult;

            try
            {
                var    httpRequest = HttpContext.Current.Request;
                string FileName    = string.Empty;

                if (httpRequest.Files.Count > 0)
                {
                    bool flag = false;
                    FileName = DateTime.Now.ToString("ddMMyyyyhhmmssffffffftt") + ".png";

                    string Path = ConfigurationManager.AppSettings["imgPathSave"] + "Documents\\gallery\\Group" + groupId + "\\Album" + albumId;

                    string filePath = ConfigurationManager.AppSettings["imgPathSave"] + "Documents\\gallery\\Group" + groupId + "\\Album" + albumId + "\\" + FileName;

                    foreach (string file in httpRequest.Files)
                    {
                        byte[]       imageBytes = Convert.FromBase64String(file);
                        MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);
                        ms.Write(imageBytes, 0, imageBytes.Length);
                        System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);

                        var postedFile = httpRequest.Files[file];

                        if (!Directory.Exists(Path))
                        {
                            Directory.CreateDirectory(Path);
                        }

                        //postedFile.SaveAs(filePath);
                        ReduceImageSize(0.3, ms, filePath);
                        image.Save(filePath);
                        flag = true;
                    }

                    if (flag)
                    {
                        Gallery.AddUpdateAlbumPhoto(photoId, FileName, desc, albumId, createdBy);
                        LoadImageResult = new { status = "0", message = "success" };
                    }
                    else
                    {
                        LoadImageResult = new { status = "1", message = "failed" };
                    }
                }
                else
                {
                    Gallery.AddUpdateAlbumPhoto(photoId, FileName, desc, albumId, createdBy);
                    LoadImageResult = new { status = "0", message = "success" };
                }
            }
            catch
            {
                LoadImageResult = new { status = "1", message = "failed" };
            }

            return(new { LoadImageResult });
        }