public void InitContext() { var builder = new DbContextOptionsBuilder <EmpContext>() .UseSqlServer("Server=localhost;Database=ASH;Trusted_Connection=True;MultipleActiveResultSets=true"); _context = new EmpContext(builder.Options); }
public static MeterDiagram ToViewDiagram(this MeterFullInfo node /*, int layer = 0 */) { var model = new MeterDiagram() { Id = node.Id, ParentId = node.ParentId, TreeId = node.TreeId, Rank = node.Rank, ParentName = node.ParentName, BrandId = node.BrandId, Type = node.Type, EnergyCategoryId = node.EnergyCategoryId, TypeName = node.TypeName, BrandType = node.brandName, Name = node.Name, Enable = node.Enable, Access = node.Access, Address = node.Address, HasPrivilege = 0, MacAddress = node.MacAddress, HasChildren = (node.HasChildren == null ? 0 : (int)node.HasChildren), IsTurnOn = node.IsTurnOn }; var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Meter" && x.JoinId == node.Id).ToViewList(); return(model); }
public static MeterDiagram ToViewDiagram(this Meter node /*, int layer = 0 */) { var model = new MeterDiagram() { Id = node.Id, ParentId = node.ParentId, TreeId = node.TreeId, Rank = node.Rank, ParentName = node.Parent == null ? null : node.Parent.Name, BrandId = node.BrandId, Type = node.Type, EnergyCategoryId = node.EnergyCategoryId, TypeName = node.TypeDict == null ? null : DictionaryCache.Get()[node.EnergyCategoryId].ChineseName, BrandType = node.Brand == null ? null : node.Brand.Name, Name = node.Name, Enable = node.Enable, Access = node.Access, Address = node.Address, RelayElecState = node.RelayElecState, PaulElecState = node.PaulElecState, HasPrivilege = 0, MacAddress = node.MacAddress, HasChildren = node.Children.Count(), IsTurnOn = node.IsTurnOn }; var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Meter" && x.JoinId == node.Id).ToViewList(); return(model); }
public static IEnumerable <BuildingData> ToViewList(this IEnumerable <BuildingFullInfo> nodes, CategoryDictionary suffix = CategoryDictionary.None) { var nodeList = nodes.ToList(); var results = nodes.Select(node => new BuildingData() { Id = node.Id, ParentId = node.ParentId, Parent = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent && node.ParentId.HasValue ? new BuildingData { Id = (int)node.ParentId, OrganizationId = node.ParentOrganizationId, BuildingCategoryId = node.BuildingCategoryId, GbCode = node.ParentGbCode, Name = node.ParentName, AliasName = node.ParentAliasName, Type = node.ParentType == null ? -1 : (int)node.ParentType, } : null, HasChildren = node.HasChildren == null ? 0 : (int)node.HasChildren, OrganizationId = node.OrganizationId, BuildingCategoryId = node.BuildingCategoryId, CoordinateMapId = node.CoordinateMapId, Coordinate2dId = node.Coordinate2dId, Coordinate3dId = node.Coordinate3dId, TreeId = node.TreeId, GbCode = node.GbCode, Name = node.Name, AliasName = node.AliasName, Initial = node.Initial, Type = node.Type, ManagerCount = node.ManagerCount, CustomerCount = node.CustomerCount, TotalArea = node.TotalArea, WorkingArea = node.WorkingArea, LivingArea = node.LivingArea, ReceptionArea = node.ReceptionArea, Enable = node.BuildingEnable, Description = node.Description, UpFloor = node.UpFloor, Year = node.Year, Sort = node.Sort, MaxCustomerCount = node.MaxCustomerCount, Purpose = node.Purpose }); if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField) { var ctx = new EmpContext(); results.Join(ctx.ExtensionFields.Where(x => x.Table == "Building"), o => o.Id, f => f.JoinId, (o, f) => { if (o.ExtensionFields == null) { o.ExtensionFields = new List <ExtensionFieldData>(); } o.ExtensionFields.Add(f.ToViewData()); return(o); }).ToList(); } return(results); }
public ActionResult GetData() { using (EmpContext db = new EmpContext()) { var WorkerData = db.Emps.OrderBy(a => a.Name).ToList(); return(Json(new { data = WorkerData }, JsonRequestBehavior.AllowGet)); } }
public ActionResult FillCity(int state) { EmpContext db = new EmpContext(); var cities = db.Ctys.Where(c => c.StateId == state); return(Json(cities, JsonRequestBehavior.AllowGet)); }
// GET: Employee/Delete/5 public ActionResult Delete(int id) { if (ModelState.IsValid) { EmpContext.DeleteEmployee(id); } // Go to home page after an employee has been removed return(RedirectToAction("Index", "Home")); }
public UserAccountBLL(EmpContext context = null) : base(context) { userBLL = new UserBLL(this.db); buildingBLL = new BuildingBLL(this.db); organizationBLL = new OrganizationBLL(this.db); dictionaryBLL = new DictionaryBLL(this.db); roleBLL = new RoleBLL(this.db); }
public static BuildingData ToViewData(this BuildingFullInfo node, CategoryDictionary suffix = CategoryDictionary.None) { if (node != null) { var model = new BuildingData() { Id = node.Id, ParentId = node.ParentId, Parent = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent && node.ParentId.HasValue ? new BuildingData { Id = (int)node.ParentId, OrganizationId = node.ParentOrganizationId, BuildingCategoryId = node.BuildingCategoryId, GbCode = node.ParentGbCode, Name = node.ParentName, AliasName = node.ParentAliasName, Type = node.ParentType == null ? -1 : (int)node.ParentType, } : null, HasChildren = node.HasChildren == null ? 0 : (int)node.HasChildren, OrganizationId = node.OrganizationId, BuildingCategoryId = node.BuildingCategoryId, CoordinateMapId = node.CoordinateMapId, Coordinate2dId = node.Coordinate2dId, TreeId = node.TreeId, Coordinate3dId = node.Coordinate3dId, GbCode = node.GbCode, Name = node.Name, AliasName = node.AliasName, Initial = node.Initial, Type = node.Type, ManagerCount = node.ManagerCount, CustomerCount = node.CustomerCount, TotalArea = node.TotalArea, WorkingArea = node.WorkingArea, LivingArea = node.LivingArea, ReceptionArea = node.ReceptionArea, Enable = node.BuildingEnable, Description = node.Description, UpFloor = node.UpFloor, Year = node.Year, Sort = node.Sort, MaxCustomerCount = node.MaxCustomerCount, Purpose = node.Purpose }; if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField) { var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Building" && x.JoinId == node.Id).ToViewList(); } return(model); } else { return(null); } }
public BalanceDetailBLL(EmpContext context = null) : base(context) { dictionaryBLL = new DictionaryBLL(this.db); buildingBLL = new BuildingBLL(this.db); organizationBLL = new OrganizationBLL(this.db); monitoringConfigBLL = new MonitoringConfigBLL(this.db); meterBLL = new MeterBLL(this.db); userBLL = new UserBLL(this.db); }
public static IEnumerable <Dictionary> Parameters(this Dictionary node) { if (node == null || node.Code != "EnergyCategory") { return(null); } var ecs = node.Descendants(true).Select(x => x.Id); var ctx = new EmpContext(); return(ctx.Meters.Where(x => ecs.Contains(x.EnergyCategoryId)).SelectMany(x => x.MeterMonthlyResults).Where(x => x.Parameter.Type.SecondValue.HasValue && x.Parameter.Type.SecondValue.Value == 1).Select(x => x.Parameter.Type).Distinct().ToList()); }
public HistoryBillBLL(EmpContext context = null) : base(context) { dictionaryBLL = new DictionaryBLL(this.db); buildingBLL = new BuildingBLL(this.db); organizationBLL = new OrganizationBLL(this.db); //monitoringConfigBLL = new MonitoringConfigBLL(this.db); meterBLL = new MeterBLL(this.db); userBLL = new UserBLL(this.db); messageBLL = new MessageBLL(this.db); }
public ActionResult Create(Employee employee) { if (ModelState.IsValid) { var result = EmpContext.SaveEmployee(employee); return(RedirectToAction("Details", new { id = result })); } // Go to home page after a post has been created return(RedirectToAction("Index", "Home")); }
public MessageBLL(EmpContext context = null) : base(context) { userBLL = new UserBLL(this.db); subscribeBLL = new SubscribeBLL(this.db); buildingBLL = new BuildingBLL(this.db); organizationBLL = new OrganizationBLL(this.db); messageRecordBLL = new MessageRecordBLL(this.db); userBLL = new UserBLL(this.db); subscribeBLL = new SubscribeBLL(this.db); }
public EmpController(EmpContext context) { _context = context; if (_context.EmpCollection.Count() == 0) { _context.EmpCollection.Add(new Employee { FirstName = "John", LastName = "Doe", DateOfJoining = System.DateTime.Now, Manager = "Tom", IsActive = true }); _context.SaveChanges(); } }
private static void Main(string[] args) { using (var db = new EmpContext()) { System.Console.WriteLine("Preparing database"); db.Database.EnsureDeleted(); db.Database.EnsureCreated(); System.Console.WriteLine("Done."); } }
private static bool HasMeterResult(this Dictionary node) { try { return(node.Descendants(true).SelectMany(n => n.MetersByEnergyCategory).Any(x => x.MeterMonthlyResults.Count > 0)); } catch (Exception) { var ctx = new EmpContext(); var ids = node.Descendants(true).Select(x => x.Id); return(ctx.Dictionaries.Where(x => ids.Contains(x.Id)).SelectMany(n => n.MetersByEnergyCategory).Any(x => x.MeterMonthlyResults.Count > 0)); } }
public Repository(EmpContext context = null, Expression <Func <TObject, bool> > predicate = null) { this.db = context == null ? new EmpContext() : context; if (predicate == null) { this._predicate = i => true; } else { this._predicate = predicate; } //shareContext = true; }
public static BuildingDiagram ToViewDiagram(this Building node, int layer = 0, CategoryDictionary suffix = CategoryDictionary.None) { if (node.Parent != null) { node.Parent.Parent = null; } var model = new BuildingDiagram() { Id = node.Id, ParentId = node.ParentId, OrganizationId = node.OrganizationId, BuildingCategoryId = node.BuildingCategoryId, CoordinateMapId = node.CoordinateMapId, Coordinate2dId = node.Coordinate2dId, Coordinate3dId = node.Coordinate3dId, GbCode = node.GbCode, Name = node.Name, AliasName = node.AliasName, Initial = node.Initial, Type = node.Type, ManagerCount = node.ManagerCount, CustomerCount = node.CustomerCount, TotalArea = node.TotalArea, WorkingArea = node.WorkingArea, LivingArea = node.LivingArea, ReceptionArea = node.ReceptionArea, Enable = node.Enable, Description = node.Description, UpFloor = node.UpFloor, Year = node.Year, Sort = node.Sort, Parent = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent ? (node.Parent == null ? null : node.Parent.ToViewDiagram()) : null, Organization = (suffix & CategoryDictionary.Organization) == CategoryDictionary.Organization ? (node.Organization == null ? null : node.Organization.ToViewDiagram()) : null }; if (layer > 0 && node.Children != null && node.Children.Count() != 0 && (suffix & CategoryDictionary.Children) == CategoryDictionary.Children) { model.Children = node.Children.Select(o => o.ToViewDiagram(--layer)); } else { model.Children = null; } if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField) { var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Building" && x.JoinId == node.Id).ToViewList(); } return(model); }
/// <summary> /// Create an instance of the Mfg to MfgLibraries relationships /// </summary> public RwQueryMfgViewModel() { ReferenceMfgLibrariesGroupBoxHeader = "Reference Mfg libraries"; StudyMfgFeaturesGroupBoxHeader = "Mfg features in current study"; ExportGroupBoxHeader = "Data export"; ReferenceMfgLibraries = new ObservableCollection <RwMfGLibrary>(); StudyMfgFeatures = new ObservableCollection <RwMfgFeature>(); AddReferenceMfgLibrariesCommand = new RwActionCommand(AddReferenceMfgLibrariesExecuted, AddReferenceMfgLibrariesCanExecute); ClearReferenceMfgLibrariesCommand = new RwActionCommand(ClearReferenceMfgLibrariesExecuted, ClearReferenceMfgLibrariesCanExecute); ExportRuleCommand = new RwActionCommand(ExportRuleExecuted, ExportRuleCanExecute); ExportStudyMfgFeaturesCommand = new RwActionCommand(ExportStudyFeaturesExecuted, ExportStudyFeaturesCanExecute); empContext = new EmpApplication().Context; exportRule = "A"; }
public static OrganizationData ToViewData(this Organization node, CategoryDictionary suffix = CategoryDictionary.None) { if (node == null) { return(null); } var model = new OrganizationData() { Id = node.Id, ParentId = node.ParentId, TreeId = node.TreeId, Rank = node.Rank, Parent = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent && node.ParentId.HasValue ? node.Parent.ToViewData(suffix) : null, HasChildren = node.Children.Count, Children = (suffix & CategoryDictionary.Children) == CategoryDictionary.Children ? node.Children.ToList().Select(c => c.ToViewData()).ToList() : null, Name = node.Name, AliasName = node.AliasName, Initial = node.Initial, Type = node.Type, TypeDict = (suffix & CategoryDictionary.Dictionary) == CategoryDictionary.Dictionary ? node.TypeDict.ToViewData() : null, ManagerCount = node.ManagerCount, CustomerCount = node.CustomerCount, ProvinceId = node.ProvinceId, CityId = node.CityId, DistrictId = node.DistrictId, Enable = node.Enable, Users = (suffix & CategoryDictionary.User) == CategoryDictionary.User ? node.Users.ToList().Select(u => u.ToViewData()).ToList() : null, Buildings = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? node.Buildings.ToList().Select(b => b.ToViewData()).ToList() : null, Description = node.Description }; if ((suffix & CategoryDictionary.Descendant) == CategoryDictionary.Descendant) { model.Descendants = node.Descendants(false).Select(x => x.ToViewData()).ToList(); } if ((suffix & CategoryDictionary.Ancestor) == CategoryDictionary.Ancestor) { model.Ancestors = node.Ancestors().Select(x => x.ToViewData()).ToList(); } if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField) { var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Organization" && x.JoinId == node.Id).ToViewList(); } return(model); }
// GET: Employee/Details/5 public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index", "Home")); } Employee emp = null; if (ModelState.IsValid) { emp = EmpContext.GetEmployee(id.Value); } // Go to home page if model is not valid return(View(emp)); }
public static OrganizationDiagram ToViewDiagram(this Organization node, int layer = 0, CategoryDictionary suffix = CategoryDictionary.None) { if (node.Parent != null) { node.Parent.Parent = null; } var model = new OrganizationDiagram() { Id = node.Id, ParentId = node.ParentId, TreeId = node.TreeId, Rank = node.Rank, Name = node.Name, AliasName = node.AliasName, Initial = node.Initial, ManagerCount = node.ManagerCount, CustomerCount = node.CustomerCount, Enable = node.Enable, Description = node.Description, HasChildren = node.Children.Count, Parent = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent ? (node.Parent == null ? null : node.Parent.ToViewDiagram()) : null, Buildings = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? node.Buildings.ToList().Select(b => b.ToViewData()).ToList() : null }; if (layer > 0 && node.Children != null && node.Children.Count() != 0 && (suffix & CategoryDictionary.Children) == CategoryDictionary.Children) { model.Children = node.Children.Select(o => o.ToViewDiagram(--layer)); } else { model.Children = null; } if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField) { var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Organization" && x.JoinId == node.Id).ToViewList(); } return(model); }
public static PermissionData ToViewData(this Permission node, CategoryDictionary suffix = CategoryDictionary.None) { var model = new PermissionData() { Id = node.Id, ParentId = node.ParentId, Title = node.Title, Area = node.Area, Controller = node.Controller, Action = node.Action, Value = node.Value, HttpMethod = node.HttpMethod, Url = node.Url, IsNav = node.IsNav, Actived = node.Actived, Disabled = node.Disabled, Sort = node.Sort, Description = node.Description, CategoryID = node.CategoryID, CategoryTitle = node.CategoryTitle, Icon = node.Icon }; if ((suffix & CategoryDictionary.Children) == CategoryDictionary.Children && node.Children.Count > 0) { model.Children = node.Children.Select(x => x.ToViewData(suffix)).ToList(); } if ((suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent && node.Parent != null) { model.Parent = node.Parent.ToViewData(CategoryDictionary.None); } if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField) { var ctx = new EmpContext(); model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Permission" && x.JoinId == node.Id).ToViewList(); } return(model); }
public SupervisorsController(EmpContext context) { _context = context; }
public EmployeeRepository(EmpContext context) { }
public VMDepartmentCommand(EmpContext context) { this.context = context; }
public EmpContext Get() { return(dataContext ?? (dataContext = new EmpContext())); }
public SceneModeConfigBLL(EmpContext context = null) : base(context) { }
public StandardsController(EmpContext context) { _context = context; }