Exemplo n.º 1
0
 public ActionResult ProfileEdit()
 {
     ProfileEditProfileViewResult result = new ProfileEditProfileViewResult();
     result.Profile = ProfileRepository.GetProfile(user.ProfileId);
     result.ProfileSex = ProfileSexRepository.ProfileSex;
     result.ProfileActivity = ProfileActivityRepository.ProfileActivity;
     result.Interests = ProfileInteresRepository.ProfileInteres;
     return View(result);
 }
Exemplo n.º 2
0
 public ActionResult ProfileEditAvatar()
 {
     ProfileEditProfileViewResult result = new ProfileEditProfileViewResult();
     result.Profile = ProfileRepository.GetProfile(user.ProfileId);
     result.ProfileSex = ProfileSexRepository.ProfileSex;
     result.ProfileAlcohol = ProfileAlcoholRepository.ProfileAlcohol;
     result.ProfileSmoking = ProfileSmokingRepository.ProfileSmoking;
     result.ProfileAnimals = ProfileAnimalsRepository.ProfileAnimals;
     result.ProfileActivity = ProfileActivityRepository.ProfileActivity;
     result.Interests = ProfileInteresRepository.ProfileInteres;
     return View(result);
 }
Exemplo n.º 3
0
 public ActionResult ProfileEdit(ProfileEditProfileViewResult newProfile)
 {
     if( (ModelState.IsValid))
     {
         newProfile.Profile.New = false;
         ProfileRepository.UpdateProfile(newProfile.Profile, ProfileUpdateMode.Main);
         TempData["toastrMessage"] = String.Format("Профиль {0} изменен", user.UserName);
         TempData["toastrType"] = "success";
         newProfile.ProfileSex = ProfileSexRepository.ProfileSex;
         newProfile.ProfileActivity = ProfileActivityRepository.ProfileActivity;
         newProfile.Profile = ProfileRepository.GetProfile(newProfile.Profile.ProfileId);
         return View(newProfile);
     }
     else
     {
         newProfile.ProfileSex = ProfileSexRepository.ProfileSex;
         newProfile.ProfileActivity = ProfileActivityRepository.ProfileActivity;
         newProfile.Profile = ProfileRepository.GetProfile(newProfile.Profile.ProfileId);
         return View(newProfile);
     }
 }
Exemplo n.º 4
0
 public ActionResult ProfileEditDop(ProfileEditProfileViewResult newProfile)
 {
     if( (ModelState.IsValid))
     {
         newProfile.Profile.New = false;
         ProfileRepository.UpdateProfile(newProfile.Profile, ProfileUpdateMode.Dop);
         ProfileRepository.ClearIntereses(newProfile.Profile);
         if (newProfile.SelectedInterests != null)
         {
             foreach (var interesid in newProfile.SelectedInterests)
             {
                 var addInteres = ProfileInteresRepository.GetProfileInteres(interesid);
                 ProfileRepository.AddInteres(newProfile.Profile, addInteres);
             }
         }
         newProfile.ProfileSex = ProfileSexRepository.ProfileSex;
         newProfile.ProfileAlcohol = ProfileAlcoholRepository.ProfileAlcohol;
         newProfile.ProfileSmoking = ProfileSmokingRepository.ProfileSmoking;
         newProfile.ProfileAnimals = ProfileAnimalsRepository.ProfileAnimals;
         newProfile.ProfileActivity = ProfileActivityRepository.ProfileActivity;
         newProfile.Interests = ProfileInteresRepository.ProfileInteres;
         TempData["toastrMessage"] = String.Format("Профиль {0} изменен", user.UserName);
         TempData["toastrType"] = "success";
         newProfile.Profile = ProfileRepository.GetProfile(newProfile.Profile.ProfileId);
         return View(newProfile);
     }
     else
     {
         newProfile.ProfileSex = ProfileSexRepository.ProfileSex;
         newProfile.ProfileAlcohol = ProfileAlcoholRepository.ProfileAlcohol;
         newProfile.ProfileSmoking = ProfileSmokingRepository.ProfileSmoking;
         newProfile.ProfileAnimals = ProfileAnimalsRepository.ProfileAnimals;
         newProfile.ProfileActivity = ProfileActivityRepository.ProfileActivity;
         newProfile.Interests = ProfileInteresRepository.ProfileInteres;
         newProfile.Profile = ProfileRepository.GetProfile(newProfile.Profile.ProfileId);
         return View(newProfile);
     }
 }
Exemplo n.º 5
0
        public ActionResult ProfileEditAvatar(ProfileEditProfileViewResult newProfile, double? cropx = 0, double? cropy = 0, double? croph = 0, double? cropw = 0)
        {
            if( (ModelState.IsValid))
            {
                if (newProfile.inputImage != null)
                {
                    newProfile.inputImage = newProfile.inputImage ?? Request.Files["inputImage"];
                    if (newProfile.inputImage != null)
                    {
                        var extension = Path.GetExtension(newProfile.inputImage.FileName);
                        if (!string.IsNullOrWhiteSpace(extension))
                        {
                            if (newProfile.Profile.ImageLink!=null)
                            {
                                PreviewCreator.RemoveImage(System.Web.Hosting.HostingEnvironment.MapPath(newProfile.Profile.ImageLink));
                            }
                            if (newProfile.Profile.ImageAvatarLink != null)
                            {
                                PreviewCreator.RemoveImage(System.Web.Hosting.HostingEnvironment.MapPath(newProfile.Profile.ImageAvatarLink));
                            }
                            if (newProfile.Profile.ImageAvatarBigLink != null)
                            {
                                PreviewCreator.RemoveImage(System.Web.Hosting.HostingEnvironment.MapPath(newProfile.Profile.ImageAvatarBigLink));
                            }

                            newProfile.Profile.ImageType = ("image/" + extension).Replace(".", "");
                            newProfile.Profile.ImageLink = PreviewCreator.SaveImage(newProfile.inputImage.InputStream);

                            newProfile.Profile.ImageAvatarType = ("image/" + ".jpg").Replace(".", "");
                            newProfile.Profile.ImageAvatarLink =PreviewCreator.SaveImageAndResize(newProfile.inputImage.InputStream, (int)cropx, (int)cropy, (int)cropw, (int)croph, new Size(48, 48));

                            newProfile.Profile.ImageAvatarBigType = ("image/" + ".jpg").Replace(".", "");
                            newProfile.Profile.ImageAvatarBigLink = PreviewCreator.SaveImageAndResize(newProfile.inputImage.InputStream, (int)cropx, (int)cropy, (int)cropw, (int)croph, new Size(550, 550));

                        }
                    }
                }
                else
                {
                    if ((newProfile.Profile.ImageLink != null) && (cropx != 0) && (cropy != 0) && (cropw != 0) && (croph != 0))
                    {
                        using (var fileStream = new FileStream(Server.MapPath(newProfile.Profile.ImageLink), FileMode.Open, FileAccess.Read))
                        {
                            if (newProfile.Profile.ImageAvatarLink != null)
                            {
                                PreviewCreator.RemoveImage(System.Web.Hosting.HostingEnvironment.MapPath(newProfile.Profile.ImageAvatarLink));
                            }
                            if (newProfile.Profile.ImageAvatarBigLink != null)
                            {
                                PreviewCreator.RemoveImage(System.Web.Hosting.HostingEnvironment.MapPath(newProfile.Profile.ImageAvatarBigLink));
                            }
                            newProfile.Profile.ImageAvatarType = ("image/" + ".jpg").Replace(".", "");
                            newProfile.Profile.ImageAvatarLink = PreviewCreator.SaveImageAndResize(fileStream, (int)cropx, (int)cropy, (int)cropw, (int)croph, new Size(48, 48));
                            newProfile.Profile.ImageAvatarBigType = ("image/" + ".jpg").Replace(".", "");
                            newProfile.Profile.ImageAvatarBigLink = PreviewCreator.SaveImageAndResize(fileStream, (int)cropx, (int)cropy, (int)cropw, (int)croph, new Size(550, 550)); ;

                        }
                    }
                }

                newProfile.Profile.New = false;
                ProfileRepository.UpdateProfile(newProfile.Profile, ProfileUpdateMode.Avatar);
                newProfile.Profile = ProfileRepository.GetProfile(newProfile.Profile.ProfileId);
                TempData["toastrMessage"] = String.Format("Профиль {0} изменен", user.UserName);
                TempData["toastrType"] = "success";
                return View(newProfile);
            }
            else
            {
                newProfile.ProfileSex = ProfileSexRepository.ProfileSex;
                newProfile.ProfileAlcohol = ProfileAlcoholRepository.ProfileAlcohol;
                newProfile.ProfileSmoking = ProfileSmokingRepository.ProfileSmoking;
                newProfile.ProfileAnimals = ProfileAnimalsRepository.ProfileAnimals;
                newProfile.ProfileActivity = ProfileActivityRepository.ProfileActivity;
                newProfile.Interests = ProfileInteresRepository.ProfileInteres;
                return View(newProfile);
            }
        }