public ActionResult AddPicture(AddPictureModel picture) { if (ModelState.IsValid) { try { var pictureId = CreatePicture(picture); var user = userService.GetUserEntity(User.Identity.Name); var profile = new PictureProfileBll() { Description = picture.Description, LoadingDate = DateTime.Now, PictureId = pictureId, UserId = user.Id, }; picProfileService.CreatePictureProfile(profile); TempData["MessageType"] = MessageType.success; TempData["StrongResultMessage"] = "Фото успешно загружено"; } catch (Exception) { TempData["MessageType"] = MessageType.info; TempData["StrongResultMessage"] = "Не удалось загрузить новое фото"; } return(RedirectToAction("ShowPhotoAlbum", "PhotoAlbum")); } return(View(picture)); }
public void CreatePictureProfile(PictureProfileBll profile) { if (profile == null) throw new ArgumentNullException("profile"); repository.Create(profile.ToDal()); uow.Commit(); }
public void CreatePictureProfile(PictureProfileBll profile) { if (profile == null) { throw new ArgumentNullException("profile"); } repository.Create(profile.ToDal()); uow.Commit(); }
public void DeletePictureProfile(PictureProfileBll profile) { if (profile == null) throw new ArgumentNullException("profile"); if (profile.Id <= 0) throw new InvalidIdException(); var existedProfile = repository.GetById(profile.Id); if (existedProfile == null) throw new ArgumentException("The profile cannot be found"); repository.Delete(existedProfile); uow.Commit(); }
public void UpdatePictureProfile(PictureProfileBll profile) { if (profile == null) throw new ArgumentNullException("profile"); PictureProfileDal currentPictureProfile = profile.ToDal(); PictureProfileDal existedPictureProfile = repository.GetById(profile.Id); if (existedPictureProfile == null) throw new EntityNotFoundException("profile", profile.Id); existedPictureProfile.Description = currentPictureProfile.Description; existedPictureProfile.PictureId = currentPictureProfile.PictureId; existedPictureProfile.Rating = currentPictureProfile.Rating; repository.Update(existedPictureProfile); uow.Commit(); }
public void UpdatePictureProfile(PictureProfileBll profile) { if (profile == null) { throw new ArgumentNullException("profile"); } PictureProfileDal currentPictureProfile = profile.ToDal(); PictureProfileDal existedPictureProfile = repository.GetById(profile.Id); if (existedPictureProfile == null) { throw new EntityNotFoundException("profile", profile.Id); } existedPictureProfile.Description = currentPictureProfile.Description; existedPictureProfile.PictureId = currentPictureProfile.PictureId; existedPictureProfile.Rating = currentPictureProfile.Rating; repository.Update(existedPictureProfile); uow.Commit(); }
public void DeletePictureProfile(PictureProfileBll profile) { if (profile == null) { throw new ArgumentNullException("profile"); } if (profile.Id <= 0) { throw new InvalidIdException(); } var existedProfile = repository.GetById(profile.Id); if (existedProfile == null) { throw new ArgumentException("The profile cannot be found"); } repository.Delete(existedProfile); uow.Commit(); }
private PictureProfileModel Map(PictureProfileBll profile, int index) { var modelProfile = new PictureProfileModel() { Description = profile.Description, LoadingDate = profile.LoadingDate, PictureId = profile.PictureId, Index = index, UserId = profile.UserId, }; PictureBll picture = pictureService.GetPictureById(profile.PictureId); if (picture == null) { return(null); } modelProfile.Name = picture.Name; modelProfile.Image = Convert.ToBase64String(picture.Image); return(modelProfile); }
public static PictureProfileDal ToDal(this PictureProfileBll profileBll) { return(Mapper.Map <PictureProfileBll, PictureProfileDal>(profileBll)); }