public ActionResult UploadProfileImage(HttpPostedFileBase file)
        {
            string fileUrl        = "";
            float  SizeInMegaByte = (float)(file.ContentLength) / (1024 * 1024);

            if (file != null && SizeInMegaByte <= 3)
            {
                List <string> content = file.ContentType.Split('/').ToList();
                if (content[0] == "image")
                {
                    string fileName = Path.GetFileName(file.FileName);
                    fileUrl = WebMessaging.UploadMessageAttachment(file, file.ContentType, fileName);
                    //UserDataSession userSession = SessionData;
                    // string ImgUrl = fileUrl;
                    //SessionData = userSession;
                }
            }

            else
            {
                return(View("MaxSizeImage"));
            }

            Session["PublicImageUrl"] = fileUrl;
            return(PartialView("CreateImage", fileUrl));
        }
        public ActionResult UploadProfileImage(HttpPostedFileBase file)
        {
            string userName = "";

            if (SessionData == null)
            {
                userName = SessionData.UserName;
            }
            if (file != null)
            {
                List <string> content = file.ContentType.Split('/').ToList();
                if (content[0] == "image")
                {
                    string          fileName    = Path.GetFileName(file.FileName);
                    string          fileUrl     = WebMessaging.UploadMessageAttachment(file, file.ContentType, fileName);
                    UserDataSession userSession = SessionData;
                    userSession.ImgUrl = fileUrl;
                    SessionData        = userSession;
                }
            }
            return(PartialView("CreateImage", SessionData.ImgUrl));
        }
 public ActionResult UploadIndexImage(HttpPostedFileBase file)
 {
     try
     {
         List <string> content = file.ContentType.Split('/').ToList();
         if (content[0] == "image")
         {
             string userName = "";
             if (SessionData == null)
             {
                 userName = SessionData.UserName;
             }
             EditProfileModel generaladmin = EmployeesLogic.GetEditProfileModel(userName);
             string           fileName     = Path.GetFileName(file.FileName);
             string           fileUrl      = WebMessaging.UploadMessageAttachment(file, file.ContentType, fileName);
             generaladmin.ImgURL = fileUrl;
             EmployeesLogic.UpdateEmployee(generaladmin);
             EmployeeUsersDetails model = new EmployeeUsersDetails {
                 ImgURL = fileUrl
             };
             return(RedirectToAction("Index", "Home", model));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     catch (Exception e)
     {
         LogsLogic.InsertLog(new Log()
         {
             Message    = e.Message,
             StackTrace = e.StackTrace,
             StoryName  = "ManagementProject/ImageUpload/UploadIndexImage",
             Parameters = new JavaScriptSerializer().Serialize(file)
         });
         return(RedirectToAction("GeneralError", "Error", new { ErrorMessage = Error.ServerNotRespond }));
     }
 }