コード例 #1
0
ファイル: VideoController.cs プロジェクト: patrickwensel/WS
        public ActionResult AreaCreate([DataSourceRequest] DataSourceRequest request, AreaViewModel areaViewModel)
        {
            try
            {
                if (areaViewModel != null && ModelState.IsValid)
                {
                    using (var context = new ASJDE())
                    {
                        var videoArea = new VideoArea
                        {
                            CompanyID = areaViewModel.CompanyID,
                            StrategicBusinessUnitID   = areaViewModel.StrategicBusinessUnitID,
                            OperationalBusinessUnitID = areaViewModel.OperationalBusinessUnitID,
                            BusinessUnitID            = areaViewModel.BusinessUnitID,
                            BranchID = areaViewModel.BranchID,
                            DepotID  = areaViewModel.DepotID,
                            Name     = areaViewModel.Name
                        };

                        context.VideoAreas.Add(videoArea);
                        context.SaveChanges();

                        areaViewModel.ID = videoArea.ID;
                    }
                }

                return(Json(new[] { areaViewModel }.ToDataSourceResult(request, ModelState)));
            }
            catch (Exception e)
            {
                Logger.Error("Exception", e);
                return(null);
            }
        }
コード例 #2
0
ファイル: VideoController.cs プロジェクト: patrickwensel/WS
        public VideoArea GetAreaById(int areaId)
        {
            var videoArea = new VideoArea();

            try
            {
                using (var context = new ASJDE())
                {
                    videoArea = context.VideoAreas.FirstOrDefault(va => va.ID == areaId);
                }
            }
            catch (Exception e)
            {
                Logger.Error("Exception", e);
            }

            return(videoArea);
        }
コード例 #3
0
ファイル: VideoController.cs プロジェクト: patrickwensel/WS
        public VideoArea GetAreaById(int areaId)
        {
            var videoArea = new VideoArea();

            try
            {
                using (var context = new ASJDE())
                {
                    videoArea = context.VideoAreas.FirstOrDefault(va => va.ID == areaId);
                }
            }
            catch (Exception e)
            {
                Logger.Error("Exception", e);
            }

            return videoArea;
        }
コード例 #4
0
ファイル: VideoController.cs プロジェクト: patrickwensel/WS
        public ActionResult AreaCreate([DataSourceRequest] DataSourceRequest request, AreaViewModel areaViewModel)
        {
            try
            {
                if (areaViewModel != null && ModelState.IsValid)
                {
                    using (var context = new ASJDE())
                    {
                        var videoArea = new VideoArea
                            {
                                CompanyID = areaViewModel.CompanyID,
                                StrategicBusinessUnitID = areaViewModel.StrategicBusinessUnitID,
                                OperationalBusinessUnitID = areaViewModel.OperationalBusinessUnitID,
                                BusinessUnitID = areaViewModel.BusinessUnitID,
                                BranchID = areaViewModel.BranchID,
                                DepotID = areaViewModel.DepotID,
                                Name = areaViewModel.Name
                            };

                        context.VideoAreas.Add(videoArea);
                        context.SaveChanges();

                        areaViewModel.ID = videoArea.ID;
                    }
                }

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