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); } }
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); }
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; }
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; } }