public ActionResult EditPersonalDetails(PersonalDetails model) { if (ModelState.IsValid) { _IUserInformationRepository.EditUserInformation(new UserInformation { id = model.PersonalID, first_name = model.FirstName, last_name = model.LastName, gender = model.Gender, register_date = model.RegisterDate }); TempData["Success"] = "Pomyślnie edytowano dane personalne."; } else { TempData["Warning"] = "Wystąpił błąd. Spróbuj jeszcze raz."; } return(RedirectToAction("Index")); }
public ActionResult SetPhoto(SetPhotoModel model) { if (ModelState.IsValid) { var result = UploadPhoto(model.PhotoFile); if (result) { var photo = new Photo { url = Url.Content("/Images/Photos/" + model.PhotoFile.FileName) }; if (!CurrentUserInfo.photo_id.HasValue) { _IPhotosRepository.AddPhoto(photo); _IUserInformationsRepository.EditUserInformation(new UserInformation { id = CurrentUserInfo.id, address_id = CurrentUserInfo.address_id, first_name = CurrentUserInfo.first_name, last_name = CurrentUserInfo.last_name, gender = CurrentUserInfo.gender, photo_id = photo.id, register_date = CurrentUserInfo.register_date }); } else { var oldPhotoPath = _IPhotosRepository.Photos.FirstOrDefault(x => x.id == CurrentUserInfo.photo_id.Value).url; var fullPath = Server.MapPath(oldPhotoPath); DeletePhoto(fullPath); photo.id = CurrentUserInfo.photo_id.Value; _IPhotosRepository.ChangePhoto(photo); } } } else { TempData["Warning"] = "Zdjęcie musi mieć rozszerzenie .jpg, .jpeg lub .png i rozmiar niewiększy niż 3MB."; } return(RedirectToAction("SetPhoto")); }