Beispiel #1
0
 public ActionResult SaveProfilePhoto(HttpPostedFileBase file, string ProfileID)
 {
     if (file != null && file.ContentLength > 0)
     {
         try
         {
             Mugurtham.Core.Login.LoggedInUser      objLoggedIn      = (Mugurtham.Core.Login.LoggedInUser)Session["LoggedInUser"];
             Mugurtham.Core.BasicInfo.BasicInfoCore objBasicInfoCore = new Core.BasicInfo.BasicInfoCore(ref objLoggedIn);
             using (objBasicInfoCore as IDisposable)
             {
                 Mugurtham.Core.BasicInfo.BasicInfoCoreEntity objBasicInfoCoreEntity = new Core.BasicInfo.BasicInfoCoreEntity();
                 using (objBasicInfoCoreEntity as IDisposable)
                 {
                     objBasicInfoCoreEntity           = objBasicInfoCore.GetByProfileID(ProfileID);
                     objBasicInfoCoreEntity.PhotoPath = "/Areas/Profile/Images/ProfilePhoto/" + objLoggedIn.CommunityName + "/" + ProfileID + Path.GetExtension(Path.GetFileName(file.FileName));
                     string strFilePath = Path.Combine(Server.MapPath("~/Areas/Profile/Images/ProfilePhoto"),
                                                       ProfileID + Path.GetExtension(Path.GetFileName(file.FileName)));
                     file.SaveAs(strFilePath);
                     addTextWatermark(strFilePath);
                     objBasicInfoCore.Edit(ref objBasicInfoCoreEntity);
                 }
                 objBasicInfoCoreEntity = null;
             }
             objBasicInfoCore = null;
         }
         catch (Exception ex)
         {
             ViewBag.Message = "ERROR:" + ex.Message.ToString();
         }
     }
     else
     {
         ViewBag.Message = "You have not specified a file.";
     }
     return(Redirect("/Matrimony#/Photo"));
 }
Beispiel #2
0
 public ActionResult SaveProfilePhotoAlbum(List<HttpPostedFileBase> file, string ProfileID)
 {
     string strFileName = string.Empty;
     string strProfilePhotoPath = string.Empty;
     int intProfilePhotoIndex = 1;
     // Create if profile directory does not exsist
     string strProfileFolderPath = Path.Combine(Server.MapPath("~/Areas/Profile/Images/ProfilePhoto/" + ProfileID));
     if (!Directory.Exists(strProfileFolderPath))
         Directory.CreateDirectory(strProfileFolderPath);
     foreach (HttpPostedFileBase item in file)
     {
         if (item != null)
         {
             strFileName = Helpers.primaryKey;
             strProfilePhotoPath = "/Areas/Profile/Images/ProfilePhoto/" + ProfileID + "/" + strFileName + Path.GetExtension(Path.GetFileName(item.FileName));
         }
         //if (Array.Exists(model.FilesToBeUploaded.Split(','), s => s.Equals(item.FileName)))
         if (
             Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".jpg".ToString().ToLower() ||
             Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".jpeg".ToString().ToLower() ||
             Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".gif".ToString().ToLower() ||
             Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".png".ToString().ToLower()
             )
         {
             try
             {
                 Mugurtham.Core.Login.LoggedInUser objLoggedIn = (Mugurtham.Core.Login.LoggedInUser)Session["LoggedInUser"];
                 Mugurtham.Core.BasicInfo.BasicInfoCore objBasicInfoCore = new Core.BasicInfo.BasicInfoCore();
                 using (objBasicInfoCore as IDisposable)
                 {
                     Mugurtham.Core.BasicInfo.BasicInfoCoreEntity objBasicInfoCoreEntity = new Core.BasicInfo.BasicInfoCoreEntity();
                     using (objBasicInfoCoreEntity as IDisposable)
                     {
                         objBasicInfoCoreEntity = objBasicInfoCore.GetByProfileID(ProfileID);
                         objBasicInfoCoreEntity.PhotoPath = strProfilePhotoPath;
                         string strFilePath = Path.Combine(Server.MapPath("~/Areas/Profile/Images/ProfilePhoto/" + ProfileID),
                                           strFileName + Path.GetExtension(Path.GetFileName(item.FileName)));
                         item.SaveAs(strFilePath);
                         savePhotoToFolder(strProfilePhotoPath, ProfileID);
                         if (intProfilePhotoIndex == 1)
                             objBasicInfoCore.Edit(ref objBasicInfoCoreEntity);
                     }
                     objBasicInfoCoreEntity = null;
                 }
                 objBasicInfoCore = null;
             }
             catch (Exception ex)
             {
                 ViewBag.Message = "ERROR:" + ex.Message.ToString();
             }
         }
         intProfilePhotoIndex += 1;
     }
     return Redirect("/Mugurtham#/Photo");
 }
Beispiel #3
0
 public ActionResult SaveProfilePhotoAlbum(List <HttpPostedFileBase> file, string ProfileID)
 {
     try
     {
         string strFileName          = string.Empty;
         string strProfilePhotoPath  = string.Empty;
         int    intProfilePhotoIndex = 1;
         // Create if profile directory does not exsist
         Mugurtham.Core.Login.LoggedInUser objLoggedIn = (Mugurtham.Core.Login.LoggedInUser)Session["LoggedInUser"];
         string strProfileFolderPath = Path.Combine(Server.MapPath("~/Areas/Profile/Images/ProfilePhoto/" + objLoggedIn.CommunityName.Trim() + "/" + ProfileID));
         if (!Directory.Exists(strProfileFolderPath))
         {
             Directory.CreateDirectory(strProfileFolderPath);
         }
         foreach (HttpPostedFileBase item in file)
         {
             if (item != null)
             {
                 strFileName         = Helpers.primaryKey;
                 strProfilePhotoPath = "/Areas/Profile/Images/ProfilePhoto/" + objLoggedIn.CommunityName + "/" + ProfileID + "/" + strFileName + Path.GetExtension(Path.GetFileName(item.FileName));
             }
             //if (Array.Exists(model.FilesToBeUploaded.Split(','), s => s.Equals(item.FileName)))
             if (
                 Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".jpg".ToString().ToLower() ||
                 Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".jpeg".ToString().ToLower() ||
                 Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".gif".ToString().ToLower() ||
                 Path.GetExtension(Path.GetFileName(item.FileName)).ToString().ToLower() == ".png".ToString().ToLower()
                 )
             {
                 try
                 {
                     Mugurtham.Core.BasicInfo.BasicInfoCore objBasicInfoCore = new Core.BasicInfo.BasicInfoCore(ref objLoggedIn);
                     using (objBasicInfoCore as IDisposable)
                     {
                         Mugurtham.Core.BasicInfo.BasicInfoCoreEntity objBasicInfoCoreEntity = new Core.BasicInfo.BasicInfoCoreEntity();
                         using (objBasicInfoCoreEntity as IDisposable)
                         {
                             objBasicInfoCoreEntity           = objBasicInfoCore.GetByProfileID(ProfileID);
                             objBasicInfoCoreEntity.PhotoPath = strProfilePhotoPath;
                             string strFilePath = Path.Combine(Server.MapPath("~/Areas/Profile/Images/ProfilePhoto/" + objLoggedIn.CommunityName.Trim() + "/" + ProfileID.Trim()),
                                                               strFileName + Path.GetExtension(Path.GetFileName(item.FileName)));
                             item.SaveAs(strFilePath);
                             addTextWatermark(strFilePath);
                             savePhotoToFolder(strProfilePhotoPath, ProfileID);
                             if (intProfilePhotoIndex == 1)
                             {
                                 objBasicInfoCore.Edit(ref objBasicInfoCoreEntity);
                             }
                         }
                         objBasicInfoCoreEntity = null;
                     }
                     objBasicInfoCore = null;
                 }
                 catch (Exception ex)
                 {
                     ViewBag.Message = "ERROR:" + ex.Message.ToString();
                 }
             }
             intProfilePhotoIndex += 1;
         }
     }
     catch (Exception objEx)
     {
         Helpers.LogExceptionInFlatFile(objEx);
     }
     return(Redirect("/Matrimony#/Photo"));
 }
Beispiel #4
0
 public ActionResult SaveProfilePhoto(HttpPostedFileBase file, string ProfileID)
 {
     if (file != null && file.ContentLength > 0)
         try
         {
             Mugurtham.Core.Login.LoggedInUser objLoggedIn = (Mugurtham.Core.Login.LoggedInUser)Session["LoggedInUser"];
             Mugurtham.Core.BasicInfo.BasicInfoCore objBasicInfoCore = new Core.BasicInfo.BasicInfoCore();
             using (objBasicInfoCore as IDisposable)
             {
                 Mugurtham.Core.BasicInfo.BasicInfoCoreEntity objBasicInfoCoreEntity = new Core.BasicInfo.BasicInfoCoreEntity();
                 using (objBasicInfoCoreEntity as IDisposable)
                 {
                     objBasicInfoCoreEntity = objBasicInfoCore.GetByProfileID(ProfileID);
                     objBasicInfoCoreEntity.PhotoPath = "/Areas/Profile/Images/ProfilePhoto/" + ProfileID + Path.GetExtension(Path.GetFileName(file.FileName));
                     string strFilePath = Path.Combine(Server.MapPath("~/Areas/Profile/Images/ProfilePhoto"),
                                       ProfileID + Path.GetExtension(Path.GetFileName(file.FileName)));
                     file.SaveAs(strFilePath);
                     objBasicInfoCore.Edit(ref objBasicInfoCoreEntity);
                 }
                 objBasicInfoCoreEntity = null;
             }
             objBasicInfoCore = null;
         }
         catch (Exception ex)
         {
             ViewBag.Message = "ERROR:" + ex.Message.ToString();
         }
     else
     {
         ViewBag.Message = "You have not specified a file.";
     }
     return Redirect("/Mugurtham#/Photo");
 }