/// <summary> /// Updates the user photo. /// </summary> /// <param name="userPhoto">The user photo.</param> /// <returns></returns> public Response <UserPhotoModel> UpdateUserPhoto(UserPhotoModel userPhoto) { var spParameters = BuildUserPhotoSpParams(userPhoto, true); var repository = _unitOfWork.GetRepository <UserPhotoModel>(); return(_unitOfWork.EnsureInTransaction(repository.ExecuteNQStoredProc, "usp_UpdateUserPhoto", spParameters, forceRollback: userPhoto.ForceRollback.GetValueOrDefault(false))); }
public ActionResult Delete(UserPhotoModel photo) { var photoModel = _photoService.GetPhoto(photo.Id); _photoService.RemovePhoto(new UserPhotoBLL() { Id = photo.Id, }); System.IO.File.Delete(Server.MapPath(photoModel.PhotoAddress)); return(RedirectToAction("Photos")); }
public ActionResult HomePage(User user) { UserPhotoModel model = new UserPhotoModel(); AccountService service = new AccountService(); LoginResponse response = service.Login(user.Name, user.Password); model.User = response.User; Session["model"] = model; if (response.Code == (int)Constants.ERROR_ENUMS.SUCCESS) { return(RedirectToAction("PhotoPage", "Galery")); } return(View(model)); }
/// <summary> /// Builds the user photo sp parameters. /// </summary> /// <param name="userPhoto">The user photo.</param> /// <param name="isUpdate">if set to <c>true</c> [is update].</param> /// <returns></returns> private List <SqlParameter> BuildUserPhotoSpParams(UserPhotoModel userPhoto, bool isUpdate) { var spParameters = new List <SqlParameter>(); if (isUpdate) { spParameters.Add(new SqlParameter("UserPhotoID", userPhoto.UserPhotoID)); } spParameters.Add(new SqlParameter("UserID", (object)userPhoto.UserID ?? DBNull.Value)); spParameters.Add(new SqlParameter("PhotoID", (object)userPhoto.PhotoID ?? DBNull.Value)); spParameters.Add(new SqlParameter("IsPrimary", (object)userPhoto.IsPrimary ?? DBNull.Value)); spParameters.Add(new SqlParameter("ModifiedOn", userPhoto.ModifiedOn ?? DateTime.Now)); return(spParameters); }
public ActionResult OnAvatar(UserPhotoModel photo) { try { _photoService.EditPhoto(new UserPhotoBLL() { Id = photo.Id, IsAvatar = true }); return(RedirectToAction("Photos")); } catch { return(View()); } }
// GET: Galery public ActionResult PhotoPage(int?page) { PhotoService photoService = new PhotoService(); UserPhotoModel model = (UserPhotoModel)Session["model"]; if (page == null) { PhotoResponse photoResponse = photoService.GetPhotos(model.User); model.Photos = photoResponse.Photos; } else { PhotoResponse photoResponse = photoService.GetPhotosPartByPart(model.User, (int)page); model.Photos = photoResponse.Photos; } return(View(model)); }
public ActionResult Edit(UserPhotoModel photo) { try { if (!string.IsNullOrEmpty(photo.Description)) { _photoService.EditPhoto(new UserPhotoBLL() { Id = photo.Id, Description = photo.Description }); } return(RedirectToAction("Photos", new { id = User.Identity.GetUserId() })); } catch { return(View()); } }
public void AddUserPhoto_Failed() { // Arrange var url = baseRoute + "addUserPhoto"; var userPhoto = new UserPhotoModel { UserID = -1, IsPrimary = true, PhotoID = 1, ForceRollback = true }; // Act var response = communicationManager.Post <UserPhotoModel, Response <UserPhotoModel> >(userPhoto, url); // Assert Assert.IsTrue(response != null, "Response can't be null"); Assert.IsTrue(response.ResultCode != 0, "User photo is created for invalid data."); }
public void UpdateUserPhoto_Success() { // Arrange var url = baseRoute + "updateUserPhoto"; var userPhoto = new UserPhotoModel { UserPhotoID = 1, UserID = 5, IsPrimary = false, PhotoID = 1, ForceRollback = true }; // Act var response = communicationManager.Put <UserPhotoModel, Response <UserPhotoModel> >(userPhoto, url); // Assert Assert.IsTrue(response != null, "Response can't be null"); Assert.IsTrue(response.ResultCode == 0, "User photo could not be updated."); }
public void UpdateUserPhoto_Failed() { // Arrange var url = baseRoute + "updateUserPhoto"; var userPhoto = new UserPhotoModel { UserPhotoID = -1, UserID = -1, IsPrimary = false, PhotoID = 1, ForceRollback = true }; // Act var response = communicationManager.Put <UserPhotoModel, Response <UserPhotoModel> >(userPhoto, url); // Assert Assert.IsTrue(response != null, "Response can't be null"); Assert.IsTrue(response.RowAffected == 0, "User photo is updated for invalid data."); }
/// <summary> /// To the view model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static UserPhotoViewModel ToViewModel(this UserPhotoModel entity) { if (entity == null) { return(null); } var model = new UserPhotoViewModel { UserPhotoID = entity.UserPhotoID, UserID = entity.UserID, PhotoID = entity.PhotoID, PhotoBLOB = entity.PhotoBLOB, ThumbnailBLOB = entity.ThumbnailBLOB, IsPrimary = entity.IsPrimary, ModifiedOn = entity.ModifiedOn, ForceRollback = entity.ForceRollback }; return(model); }
/// <summary> /// To the model. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public static UserPhotoModel ToModel(this UserPhotoViewModel model) { if (model == null) { return(null); } var entity = new UserPhotoModel { UserPhotoID = model.UserPhotoID, UserID = model.UserID, PhotoID = model.PhotoID, PhotoBLOB = model.PhotoBLOB, ThumbnailBLOB = model.ThumbnailBLOB, IsPrimary = model.IsPrimary, ModifiedOn = model.ModifiedOn, ForceRollback = model.ForceRollback }; return(entity); }
public ActionResult Create(HttpPostedFileBase upload, UserPhotoModel model) { if (upload != null) { if (IsImage(upload)) { //string fileName = System.IO.Path.GetFileName(upload.FileName); Directory.CreateDirectory(Server.MapPath("/Content/UserPhotos/" + User.Identity.GetUserId() + "/")); string address = Server.MapPath("/Content/UserPhotos/" + User.Identity.GetUserId() + "/" + Guid.NewGuid().ToString() + "." + upload.FileName.Substring(upload.FileName.LastIndexOf(".") + 1)); upload.SaveAs(address); _photoService.AddPhoto(new UserPhotoBLL() { PhotoAddress = @"\" + address.Replace(Request.PhysicalApplicationPath, String.Empty), UserId = User.Identity.GetUserId(), Description = model.Description }); return(RedirectToAction("Photos")); } } return(View()); }
public IHttpActionResult AddMyProfilePhoto(UserPhotoModel userPhoto) { return(new HttpResult <Response <UserPhotoModel> >(userPhotoRuleEngine.AddUserPhoto(userPhoto), Request)); }
/// <summary> /// Updates the user photo. /// </summary> /// <param name="userPhoto">The user photo.</param> /// <returns></returns> public Response <UserPhotoModel> UpdateUserPhoto(UserPhotoModel userPhoto) { const string apiUrl = BaseRoute + "UpdateUserPhoto"; return(communicationManager.Put <UserPhotoModel, Response <UserPhotoModel> >(userPhoto, apiUrl)); }
/// <summary> /// Adds the user photo. /// </summary> /// <param name="userPhoto">The user photo.</param> /// <returns></returns> public Response <UserPhotoModel> AddUserPhoto(UserPhotoModel userPhoto) { return(userPhotoService.AddUserPhoto(userPhoto)); }
/// <summary> /// Updates the user photo. /// </summary> /// <param name="userPhoto">The user photo.</param> /// <returns></returns> public Response <UserPhotoModel> UpdateUserPhoto(UserPhotoModel userPhoto) { return(userPhotoService.UpdateUserPhoto(userPhoto)); }
public IHttpActionResult UpdateUserPhoto(UserPhotoModel userPhoto) { return(new HttpResult <Response <UserPhotoModel> >(userPhotoRuleEngine.UpdateUserPhoto(userPhoto), Request)); }
public IHttpActionResult UpdateUserPhoto(UserPhotoModel userPhoto) { return(new HttpResult <Response <UserPhotoModel> >(userPhotoDataProvider.UpdateUserPhoto(userPhoto), Request)); }