public VideoBO Update(VideoBO video) { using (var uow = facade.UnitOfWork) { Video vid = uow.VideoRepository.Get(video.ID); if (vid != null) { var videoUpdated = conv.Convert(video); //uow.VideoRepository.Get(video.ID).Author = video.Author; //uow.VideoRepository.Get(video.ID).Title = video.Title; vid.Author = videoUpdated.Author; vid.Title = videoUpdated.Title; //uow.VideoRepository.Get(video.ID).Genres = video.Genres; vid.Genres.RemoveAll(vg => !videoUpdated.Genres.Exists(g => g.GenreID == vg.GenreID && g.VideoID == vg.VideoID)); videoUpdated.Genres.RemoveAll(vg => vid.Genres.Exists(g => g.GenreID == vg.GenreID && g.VideoID == vg.VideoID)); vid.Genres.AddRange(videoUpdated.Genres); uow.Complete(); return(conv.Convert(vid)); } else { throw new InvalidOperationException("Video not found."); } } }
public ActionResult CreateVideo(int id) { ViewBag.ID = id; if (_session.IsLogin) { Video model = new Video(); if (id != -1) { VideoBO cls = new VideoBO(); model = cls.GetByID(id); if (model == null) { model = new Video(); } return(View(model)); } else { return(View(model)); } } else { return(RedirectToAction("index", "admin")); } }
public void CreateVideo(VideoBO v) { using (var uow = Facade.UnitOfWork) { uow.VideoRepository.CreateVideo(conv.Convert(v)); uow.Complete(); } }
internal Video Convert(VideoBO videoBO) { if (videoBO == null) { return(null); } return(new Video() { Id = videoBO.Id, Title = videoBO.Title, Genre = videoBO.Genre, Duration = videoBO.Duration, //? wont do select unless there is something. return null if there s a null Producers = videoBO.ProducerIds?.Select(pIds => new VideoProducer() { ProducerId = pIds, VideoId = videoBO.Id }).ToList() // Producers = videoBO.ProducerIds?.Select(producerId => new CustomerAddress() // { // ProducerId = producerId, // VideoId = videoBO.Id //}).ToList(), }); }
public ActionResult Video() { VideoBO cls = new VideoBO(); var model = cls.GetList(m => m.IsActive.Equals(true)); return(View(model)); }
static void AddCreatedVideo(VideoBO video) { var newVideo = bllFacade.VideoService.Create(video); ShowVideoInformation(newVideo); Console.WriteLine($"Video {newVideo.Id} added."); }
static void Main(string[] args) { var vid1 = new VideoBO { VideoName = "Gremlins", Year = 1997, Genre = "Horror", }; var vid2 = new VideoBO { VideoName = "How High", Year = 2007, Genre = "Terrible", }; bllFacade.VideoService.Create(vid1); bllFacade.VideoService.Create(vid2); string[] menuItems = { "Show videos", "Add a Video", "Delete a Video", "Edit a Video", "Exit" }; var selection = ShowMenu(menuItems); while (selection != 5) { switch (selection) { case 1: ListVideos(); break; case 2: AddVideos(); break; case 3: DeleteVideo(); break; case 4: EditVideo(); break; default: Console.WriteLine("Exit.........."); break; } selection = ShowMenu(menuItems); } Console.ReadLine(); }
public JsonResult SaveVideo(Video video) { VideoBO cls = new VideoBO(); bool IsResult = cls.Save(video); return(Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet)); }
private static VideoBO FindVideoById() { WriteLine("Enter Q to go back to the menu"); VideoBO video = null; while (video == null) { int idSearch; string input = ReadLine(); if (int.TryParse(input, out idSearch)) { return(bllFacade.VideoService.GetVideoById(idSearch)); } else if (input.ToLower().Equals("q")) { break; } else { Write("You have to input the id"); } } return(null); }
private Video Convert(VideoBO vid) { return(new Video() { Id = vid.Id, Name = vid.Name, }); }
public IActionResult Post([FromBody] VideoBO video) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(facade.VideoService.Create(video))); }
public VideoBO Add(VideoBO video) { using (var uow = facade.UnitOfWork) { var vid = uow.VideoRepository.Add(conv.Convert(video)); uow.Complete(); return(conv.Convert(vid)); } }
public VideoBO Create(VideoBO vid) { using (var uow = facade.UnitOfWork) { var newVid = uow.VideoRepository.Create(conv.Convert(vid)); uow.Complete(); return(conv.Convert(newVid)); } }
public Video Convert(VideoBO vid) { return(new Video { Id = vid.Id, Name = vid.Name, Genre = vid.Genre }); }
public void NotPostWithInvalidObject_ReturnBadRequest() { MockVideoService.Setup(s => s.Create(It.IsAny <VideoBO>())).Returns(new VideoBO()); var video = new VideoBO(); _controller.ModelState.AddModelError("", ""); var result = _controller.Post(video); Assert.IsType <BadRequestObjectResult>(result); }
internal Video Convert(VideoBO vid) { return(new Video() { Id = vid.Id, VideoLocation = vid.VideoLocation, VideoName = vid.VideoName, VideoType = vid.VideoType }); }
internal Video Convert(VideoBO vid) { return(new Video() { Id = vid.Id, VideoName = vid.VideoName, Genre = vid.Genre, VideoDat = vid.VideoDat }); }
public VideoBO Create(VideoBO vid) { //Will automatically call the dispose function at the end using (var uow = DALFac.UOW) { var newVid = uow.VidRepo.Create(Convert(vid)); uow.Complete(); return(Convert(newVid)); } }
private Video Convert(VideoBO vid) { return(new Video() { Id = vid.Id, Name = vid.Name, Director = vid.Director, Duration = vid.Duration }); }
internal Video Convert(VideoBO vid) { return(new Video() { Id = vid.Id, VideoName = vid.VideoName, Year = vid.Year, Genre = vid.Genre }); }
private Video Convert(VideoBO vid) { return(new Video() { VideoID = vid.VideoID, Title = vid.Title, Author = vid.Author, Genre = vid.Genre }); }
static void ShowVideoInformation(VideoBO video) { if (video == null) { Console.WriteLine("The video does not exist. Try again."); } else { Console.WriteLine($"{video.Id} | {video.Title} | {video.Genre} | {video.Duration}"); } }
static void Main(string[] args) { var video1 = new VideoBO() { Name = "fisk flygter fra brandbil" }; bllFacade.VideoService.Create(video1); bllFacade.VideoService.Create(new VideoBO() { Name = "mand opfinder et nyt for for hjul" }); String[] menuItems = { "List all Videos", "Add Video", "Delete Video", "Edit Video", "Exit\n" }; var selection = ShowMenu(menuItems); while (selection != 5) { switch (selection) { case 1: ListVideos(); break; case 2: AddVideos(); break; case 3: DeleteVideos(); break; case 4: EditVideos(); break; default: break; } selection = ShowMenu(menuItems); } Console.WriteLine("See ya!"); Console.ReadLine(); }
public void PostWithValidObject() { MockVideoService.Setup(s => s.Create(It.IsAny <VideoBO>())).Returns(new VideoBO()); var video = new VideoBO { Id = 1, Title = "Die Hard" }; var result = _controller.Post(video); Assert.IsType <CreatedResult>(result); }
internal Video Convert(VideoBO video) { if (video == null) { return(null); } return(new Video() { Id = video.Id, Name = video.Name, //Genre = new GenreConverter().Convert(video.Genre) }); }
internal Video Convert(VideoBO vid) { if (vid == null) { return(null); } return(new Video() { Id = vid.Id, Title = vid.Title, GenreId = vid.Genre != null ? vid.Genre.Id : vid.GenreId }); }
public VideoBO Create(VideoBO video) { if (video == null) { return(null); } using (var unitOfWork = _facade.UnitOfWork) { var createdVideo = unitOfWork.VideoRepository.Create(_converter.Convert(video)); unitOfWork.Complete(); return(_converter.Convert(createdVideo)); } }
internal Video Convert(VideoBO video) { if (video == null) { return(null); } return(new Video() { Title = video.Title, Id = video.Id, PricePeDay = video.PricePeDay }); }
internal Video Convert(VideoBO vid) { if (vid == null) { return(null); } return(new Video() { Id = vid.Id, Name = vid.Name, GenreId = vid.GenreId }); }
internal Video Convert(VideoBO vid) { if (vid == null) { return(null); } return(new Video() { Id = vid.Id, Genre = vid.Genre, Title = vid.Title, PricePerDay = vid.PricePerDay }); }
public JsonResult GetVideo() { if (_session.IsLogin) { string jsonData = "[]"; VideoBO _cls = new VideoBO(); var data = _cls.GetAll(); if (data != null) jsonData = new JavaScriptSerializer().Serialize(data); return Json(jsonData, JsonRequestBehavior.AllowGet); } else RedirectToAction("index", "admin"); return Json("[]", JsonRequestBehavior.AllowGet); }
private void RemoverVideo(DirectEventArgs e) { try { VideoVO video = new VideoBO().SelectById(e.ExtraParams["id"].ToInt32()); new VideoBO(video).DeleteUpdate(); LoadPagina(); } catch (Exception ex) { base.MostrarMensagem("Erro", "Erro ao tentar remover video.", ""); } }
public ActionResult CreateVideo(int id) { ViewBag.ID = id; if (_session.IsLogin) { Video model = new Video(); if (id != -1) { VideoBO cls = new VideoBO(); model = cls.GetByID(id); if (model == null) model = new Video(); return View(model); } else return View(model); } else return RedirectToAction("index", "admin"); }
public JsonResult DeleteVideo(int id) { if (_session.IsLogin) { VideoBO _cls = new VideoBO(); var IsResult = _cls.Delete(id); return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet); } else RedirectToAction("index", "admin"); return Json(new { IsOk = false }, JsonRequestBehavior.AllowGet); }
public ActionResult Video() { VideoBO cls = new VideoBO(); var model = cls.GetList(m => m.IsActive.Equals(true)); return View(model); }
public JsonResult SaveVideo(Video video) { VideoBO cls = new VideoBO(); bool IsResult = cls.Save(video); return Json(new { IsOk = IsResult }, JsonRequestBehavior.AllowGet); }