Пример #1
0
        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
        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
        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
        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;
            }
        }