Exemple #1
0
        public JsonResult EditPhoto(PhotoEntry model)
        {
            var i = _photo.Update(model);

            if (i > 0)
            {
                return(Json(model));
            }
            else
            {
                model = _photo.GetById(model.PhotoId);
                return(Json(model));
            }
        }
Exemple #2
0
        public static async Task <bool> UpdatePost(this PostModel post, string userId, IPhoto photoUploads,
                                                   IPhotoAccessor photoAccessor, IYoutube youtubeuploader, IVideo videoContext, IPost postContext, Post model,
                                                   IMapper mapper)
        {
            model.UserId = userId;
            PhotoUpLoadResult photoUpload;

            if (post.Photo != null)
            {
                photoUpload = photoAccessor.AddPhoto(post.Photo);
                var storedPhotoPublicId = await photoUploads.FindPhotoId(post.Id, post.ImageId);

                if (photoUpload != null)
                {
                    var delete = photoAccessor.DeletePhoto(storedPhotoPublicId.PublicId);
                    if (delete.ToLower().Equals("ok"))
                    {
                        var photo = new PhotoModel
                        {
                            PublicId   = photoUpload.PublicId,
                            Url        = photoUpload.Url,
                            UploadTime = DateTime.Now
                        };
                        storedPhotoPublicId.PublicId   = photo.PublicId;
                        storedPhotoPublicId.Url        = photo.Url;
                        storedPhotoPublicId.UploadTime = photo.UploadTime;

                        await photoUploads.Update(storedPhotoPublicId);

                        //
                    }
                }
            }

            if (post.Video != null)
            {
                var storedVideoId = await videoContext.GetVideoPublicId(post.Id, post.VideoId);


                UploadViewModel upload = new UploadViewModel();
                upload.Description = post.Video.Name;
                upload.Type        = post.Video.ContentType;
                upload.CategoryId  = String.Empty;
                upload.Title       = post.Video.FileName;
                upload.VideoTags   = new string[] { "tag1", "tag2" };
                upload.Private     = false;
                var videoUpload = await youtubeuploader.UpdateVideo(storedVideoId.PublicId, post.Video, upload);

                if (!string.IsNullOrEmpty(videoUpload.VideoId))
                {
                    // video

                    storedVideoId.DateUpdated = DateTime.Now;
                    storedVideoId.PublicId    = videoUpload.VideoId;
                    await videoContext.Update(storedVideoId);

                    // mapper.Map(video,storedVideoId);
                }
            }


            return(await videoContext.SaveChanges());
        }
Exemple #3
0
 /// <summary>
 /// 更新数据 Update(PhotoInfo entity)
 /// </summary>
 /// <param name="entity">实体类(PhotoInfo)</param>
 ///<returns>true:保存成功; false:保存失败</returns>
 public bool Update(PhotoInfo entity)
 {
     return(_photo.Update(entity));
 }