public void EditVideoShoudEditOneOrMorePropertiesInVideo()
        {
            var options   = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Database_For_Videos").Options;
            var dbContext = new ApplicationDbContext(options);
            var service   = new VideoService(dbContext);

            var model = new UpdateDeleteVideoViewModel
            {
                Title = "Edited",
            };

            var video = new Video
            {
                Title = "New",
            };

            dbContext.Videos.Add(video);
            dbContext.SaveChanges();

            var videoToEdit = dbContext.Videos.First();

            service.EditVideo(videoToEdit, model);

            Assert.Equal("Edited", videoToEdit.Title);
        }
示例#2
0
        public ActionResult Edit(int id, string t, string k, string d, string imageurl, string u, string um)
        {
            string result = "更新失败";

            if (Session["UserId"] == null)
            {
                return Content("长时间未操作,请重新登录。");
            }

            if (!string.IsNullOrEmpty(t) && !string.IsNullOrEmpty(k) && !string.IsNullOrEmpty(d) && !string.IsNullOrEmpty(imageurl) && !string.IsNullOrEmpty(u) && !string.IsNullOrEmpty(um))
            {
                VideoService videoService = new VideoService();
                Video video = videoService.GetVideoById(id);
                if (video != null)
                {
                    video.Title = t;
                    video.Keywords = k;
                    video.Description = d;
                    video.Thumbnail = imageurl;
                    video.Url = u;
                    video.UrlM = um;

                    if (videoService.EditVideo(video))
                    {
                        result = "success";
                    }
                }
            }
            else
            {
                result = "必填项不能为空";
            }
            return Content(result);
        }
示例#3
0
 public Result EditVideo(VideoModel model)
 {
     return(_service.EditVideo(model));
 }