public ActionResult _EditPhoto(string spaceKey, PhotoEditModel photoEditModel) { IUser currentUser = UserContext.CurrentUser; if (currentUser == null) { return(Json(new StatusMessageData(StatusMessageType.Hint, "您尚未登录!"))); } Photo photo = photoEditModel.AsPhoto(); if (!authorizer.Photo_Edit(photo)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = "没有编辑照片的权限", Title = "没有权限", StatusMessageType = StatusMessageType.Hint }))); } //设置标签 string relatedTags = Request.Form.Get <string>("RelatedTags"); if (!string.IsNullOrEmpty(relatedTags)) { tagService.ClearTagsFromItem(photo.PhotoId, photo.UserId); tagService.AddTagsToItem(relatedTags, photo.UserId, photo.PhotoId); } photoService.UpdatePhoto(photo, currentUser.UserId); return(Json(new { description = photo.Description })); }
public ActionResult UploadNormal(string spaceKey, long albumId = 0) { string errorMessage = string.Empty; if (!authorizer.Photo_Create(photoService.GetAlbum(albumId), out errorMessage)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = "没有权限", StatusMessageType = StatusMessageType.Hint }))); } string photoIds = Request.Form["photoIds"]; RouteValueDictionary dic = new RouteValueDictionary(); for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase postFile = Request.Files[i]; if (!string.IsNullOrEmpty(postFile.FileName)) { PhotoEditModel photoEditModel = new PhotoEditModel(); photoEditModel.AlbumId = albumId; Photo photo = photoEditModel.AsPhoto(); try { photoService.CreatePhoto(photo, postFile); photoIds += photo.PhotoId + ","; TempData["photoCount"] = i + 1; } catch (System.Exception e) { photoService.DeletePhoto(photo); TempData["photoIds"] = photoIds; TempData["errorMessage"] = e.Message.Replace("\r\n", ""); TempData["albumId"] = albumId; TempData["isContinue"] = bool.Parse(Request.Form["isContinue"]); return(RedirectToAction("UploadEdit")); } } } TempData["photoIds"] = photoIds; TempData["errorMessage"] = "success"; TempData["albumId"] = albumId; TempData["isContinue"] = bool.Parse(Request.Form["isContinue"]); return(RedirectToAction("UploadEdit")); }
public ActionResult UploadPhoto(string spaceKey, long albumId = 0) { if (albumId <= 0) { return(Json("请选择相册!")); } string errorMessage = string.Empty; if (!authorizer.Photo_Create(photoService.GetAlbum(albumId), out errorMessage)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = errorMessage, Title = "没有权限", StatusMessageType = StatusMessageType.Hint }))); } //上传照片及创建照片记录 HttpPostedFileBase postFile = Request.Files["fileData"]; PhotoEditModel photoEditModel = new PhotoEditModel(); photoEditModel.AlbumId = albumId; Photo photo = photoEditModel.AsPhoto(); try { photoService.CreatePhoto(photo, postFile); } catch (System.Exception e) { photoService.DeletePhoto(photo); return(Json(e.Message)); } return(Json(photo.PhotoId)); }