//public async Task<ActionResult> SaveEventImages(int Id)
        //{
        //    try
        //    {
        //        if (Request.Files.Count > 0)
        //        {
        //            string pathrefer = Request.UrlReferrer.ToString();
        //            string Serverpath = ImageSavePath;
        //            var postedFile = Request.Files[0];
        //            string file;
        //            //In case of IE
        //            if (Request.Browser.Browser.ToUpper() == "IE")
        //            {
        //                string[] files = postedFile.FileName.Split(new char[] { '\\' });
        //                file = files[files.Length - 1];
        //            }
        //            else // In case of other browsers
        //            {
        //                file = postedFile.FileName;
        //            }
        //            string ext = Path.GetExtension(ImageSavePath + "\\" + file);
        //            file = Guid.NewGuid() + ext; // Creating a unique name for the file
        //            await eventLogic.SaveEventImages(Id, file, CurrentUserSession.UserID ?? 0);
        //            postedFile.SaveAs(Path.Combine(ImageSavePath, file));
        //        }
        //        else
        //        {
        //            throw new Exception("No file to upload");
        //        }
        //    }
        //    catch (Exception exp)
        //    {
        //        Helpers.LogError("Event Image upload failed", exp);
        //        throw new Exception(exp.Message);
        //    }
        //    return Json(true, JsonRequestBehavior.AllowGet);
        //}

        // POST: Events/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        /// <summary>
        /// Saves images posted in an event
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="AlbumID"></param>
        /// <param name="AlbumDescription"></param>
        /// <returns></returns>
        public async Task <ActionResult> SaveEventImages(int Id, int?AlbumID, string AlbumDescription)
        {
            try
            {
                if (Request.Files.Count > 0)
                {
                    //string pathrefer = Request.UrlReferrer.ToString();
                    //string Serverpath = ImageSavePath;
                    var    postedFile = Request.Files[0];
                    string file;
                    //In case of IE
                    if (Request.Browser.Browser.ToUpper() == "IE")
                    {
                        string[] files = postedFile.FileName.Split(new char[] { '\\' });
                        file = files[files.Length - 1];
                    }
                    else // In case of other browsers
                    {
                        file = postedFile.FileName;
                    }
                    string ext = Path.GetExtension(ImageSavePath + "\\" + file);
                    file = Guid.NewGuid() + ext; // Creating a unique name for the file
                    await eventLogic.SaveEventImagesFromWeb(Id, file, CurrentUserSession.AttendesID ?? 0, AlbumID, AlbumDescription);

                    postedFile.SaveAs(Path.Combine(ImageSavePath, file));
                    string jsonkeysfilepath = HttpRuntime.AppDomainAppPath + @"\" + GoogleDriveSync.jsonkeysfile;
                    string ename            = eventLogic.GetEventName(Id);
                    GoogleDriveSync.CallSaveApi(jsonkeysfilepath, ename, Path.Combine(ImageSavePath, file));
                }
                else
                {
                    throw new Exception("No file to upload");
                }
            }
            catch (Exception exp)
            {
                Helpers.LogError("Event Image upload failed", exp);
                throw new Exception(exp.Message);
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Change Photos to base64
        /// </summary>
        /// <param name="token"></param>
        /// <param name="base64String"></param>
        /// <returns>Returns status of conversion</returns>

        public async Task <ActionResult> ChangePhotos(string token, string base64String)
        {
            if (base64String == "")
            {
                throw new APIException("Null image file.");
            }
            AttendesLogic alogic     = new AttendesLogic();
            var           uniquename = Guid.NewGuid(); // await alogic.UniqueAttendeeID(CurrentUserSession.AttendesID.Value);
            string        name       = uniquename + ".png";

            var result = alogic.ChangePhoto(CurrentUserSession.AttendesID.Value, name);

            byte[]       imageBytes = Convert.FromBase64String(base64String);
            MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);

            ms.Write(imageBytes, 0, imageBytes.Length);
            Image image = Image.FromStream(ms, true);

            image.Save(Path.Combine(ImageSavePath, name));
            string jsonkeysfilepath = HttpRuntime.AppDomainAppPath + @"\" + GoogleDriveSync.jsonkeysfile;

            GoogleDriveSync.CallSaveApi(jsonkeysfilepath, "Profile Pictures", Path.Combine(ImageSavePath, name));
            return(Json(new { Data = "Success" }, JsonRequestBehavior.AllowGet));
        }