Ejemplo n.º 1
0
        public ActionResult VideoDestroy([DataSourceRequest] DataSourceRequest request, VideoViewModel videoViewModel)
        {
            try
            {
                if (videoViewModel != null)
                {
                    using (var context = new ASJDE())
                    {
                        var video = context.Videos.FirstOrDefault(v => v.ID == videoViewModel.ID);
                        context.Videos.Remove(video);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("Exception", e);
            }

            return Json(ModelState.ToDataSourceResult());
        }
Ejemplo n.º 2
0
        public ActionResult VideoUpdate([DataSourceRequest] DataSourceRequest dataSourceRequest, VideoViewModel videoViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var context = new ASJDE())
                    {
                        var video = context.Videos.FirstOrDefault(v => v.ID == videoViewModel.ID);

                        if (video != null)
                        {
                            video.Name = videoViewModel.Name;
                            video.VideoGroupID = videoViewModel.GroupID;
                            video.ReferenceID = videoViewModel.ReferenceID;
                            context.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("Exception", e);
            }

            return Json(new[] { videoViewModel }.ToDataSourceResult(dataSourceRequest, ModelState));
        }
Ejemplo n.º 3
0
        public ActionResult VideoCreate([DataSourceRequest] DataSourceRequest request, VideoViewModel videoViewModel)
        {
            try
            {
                if (videoViewModel != null && ModelState.IsValid)
                {
                    using (var context = new ASJDE())
                    {
                        var video = new Video
                            {
                                VideoGroupID = videoViewModel.GroupID,
                                Name = videoViewModel.Name,
                                ReferenceID = videoViewModel.ReferenceID,
                                CreatedDate = DateTime.Now,
                                CreatedByUser = ""
                            };

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

                        videoViewModel.ID = video.ID;
                    }
                }

                return Json(new[] { videoViewModel }.ToDataSourceResult(request, ModelState));
            }
            catch (Exception e)
            {
                Logger.Error("Exception", e);
                return null;
            }
        }