public ActionResult EditProfile(string username) { Person CU; if (username == null) { CU = reposetory.CurrentUser(); } else { CU = reposetory.GetPerson(username); } NR.Models.PersonProfile VM = new NR.Models.PersonProfile(); VM.PersonID = CU.PersonID; VM.Username = CU.UserName; VM.FirstName = CU.FirstName; VM.FamilyName = CU.FamilyName; VM.Email = CU.Email; VM.Mobil = CU.Mobile; VM.Phone = CU.Phone; VM.Gender = CU.Gender; VM.BirthDate = CU.BirthDate; VM.Address = CU.Address; VM.Zip = CU.Zip; VM.City = CU.City; VM.Country = CU.Country; return(View(VM)); }
public ActionResult EditProfile(NR.Models.PersonProfile profile, string RadioGender, HttpPostedFileBase file, double?x, double?y, double?w, double?h) { Person CU = null; profile.Username = profile.Username.ToUpper(); if (RadioGender == "M") { profile.Gender = Gender.Man; } if (RadioGender == "F") { profile.Gender = Gender.Woman; } if (String.IsNullOrWhiteSpace(profile.Email) & string.IsNullOrWhiteSpace(profile.Mobil) & string.IsNullOrWhiteSpace(profile.Phone)) { ModelState.AddModelError("", General.ErrorNoContactInfo); } if (ModelState.IsValid) { CU = reposetory.GetPerson(profile.PersonID); if (profile.PersonID != CU.PersonID) { return(RedirectToAction("EditProfile")); //TODO: Null check } if (profile.Username != CU.UserName && !reposetory.IsUserNameUniqe(profile.Username.ToUpper())) { ModelState.AddModelError("Username", General.ErrorUsernameNotUnique); } if (!reposetory.SavePerson(CU)) { ModelState.AddModelError("Username", General.ErrorSave); } ViewBag.FormSucces = true; } if (file != null && file.ContentLength > 0) { if (CU == null) { CU = reposetory.GetPerson(profile.PersonID); } if (profile.PersonID != CU.PersonID) { return(RedirectToAction("EditProfile")); } if (CU.PersonID != Guid.Empty) { Image image = Image.FromStream(file.InputStream); if (image.Width > 428 & image.Height > 550) { var fileExt = Path.GetExtension(file.FileName); string ProfilDirSetting = ConfigurationManager.AppSettings["ProfileImage"]; if (string.IsNullOrWhiteSpace(ProfilDirSetting)) { throw new ArgumentNullException(); } var path = Server.MapPath(String.Format(ProfilDirSetting, CU.PersonID.ToString())); file.SaveAs(path); ViewBag.CropImage = true; ViewBag.ImageWidth = image.Width; ViewBag.ImageHeigh = image.Height; } else { ModelState.AddModelError("", General.ProfileImageToSmall); } } } if (x != null && y != null && h != null && w != null) { if (CU == null) { CU = reposetory.GetPerson(profile.PersonID); } if (profile.PersonID != CU.PersonID) { return(RedirectToAction("EditProfile")); } if (CU.PersonID != Guid.Empty) { if (!ModifyImage(Convert.ToInt32(x), Convert.ToInt32(y), Convert.ToInt32(w), Convert.ToInt32(h), CU)) { ModelState.AddModelError("", General.ProfileImageCropError); } } } return(View(profile)); }
public ActionResult EditProfile(string username) { Person CU; if (username == null) { CU = reposetory.CurrentUser(); } else { CU = reposetory.GetPerson(username); } NR.Models.PersonProfile VM = new NR.Models.PersonProfile(); VM.PersonID = CU.PersonID; VM.Username = CU.UserName; VM.FirstName = CU.FirstName; VM.FamilyName = CU.FamilyName; VM.Email = CU.Email; VM.Mobil = CU.Mobile; VM.Phone = CU.Phone; VM.Gender = CU.Gender; VM.BirthDate = CU.BirthDate; VM.Address = CU.Address; VM.Zip = CU.Zip; VM.City = CU.City; VM.Country = CU.Country; return View(VM); }