// Updates provided department public static void Update(Department dept) { var context = new AssetContext(); var existingDept = context.Departments.SingleOrDefault(d => d.Id == dept.Id); existingDept.Name = dept.Name; context.SaveChanges(); }
//get all assets public static List <Asset> GetAll() { var context = new AssetContext(); var assets = context.Assets. Include(a => a.AssetType).ToList(); // include statements to get nested assetType return(assets); }
public static void Update(AssetType assetType) { var context = new AssetContext(); var originalType = context.AssetTypes.Find(assetType.Id); originalType.Name = assetType.Name; context.SaveChanges(); }
//get all assets of a assettype public async static Task <List <Asset> > GetAllByAssetType(int id) { var context = new AssetContext(); var assets = await context.Assets. Where(a => a.AssetTypeId == id). Include(a => a.AssetType).ToListAsync(); // include statements to get nested assetType return(assets); }
public static Dictionary <string, decimal> GetStockPrices() { AssetContext db = new AssetContext(); List <Stock> l = db.Stocks.ToList(); //string yahooResult = GetStockPriceXML(l); //return Parse(yahooResult); return(GetStockPriceXML1(l)); }
public async Task <PagedResult <Asset> > GetPagedAssetsOverview(int page, int pageSize) { using (var context = new AssetContext()) { var paged = await context.Assets.GetPagedAsync(page, pageSize); return(paged); } }
public static List <AssetType> GetAll() { var context = new AssetContext(); //Include Asset Navigation Property var assets = context.AssetTypes.Include(a => a.Assets).ToList(); return(assets); }
// Remove an asset from its assigned employee public static void RemoveAssetFromEmployee(int assetId) { var context = new AssetContext(); Asset ast = context.Assets.SingleOrDefault(a => a.Id == assetId); ast.EmployeeId = null; ast.DateAssigned = null; context.SaveChanges(); }
// Assign an asset to a given employee public static void AssignAssetsToEmployee(int assetId, int employeeId) { var context = new AssetContext(); Asset ast = context.Assets.SingleOrDefault(a => a.Id == assetId); ast.EmployeeId = employeeId; ast.DateAssigned = DateTime.Now; context.SaveChanges(); }
public static List <Asset> GetAllByAssetType(int id) { var context = new AssetContext(); // Include the AssetType navigation property var assets = context.Assets.Where(i => i.AssetTypeId == id).Include(a => a.AssetType).ToList(); return(assets); }
// Gets assets for the given asset category ID public static IEnumerable <Asset> GetAvailableAssetsByCategory(int categoryId) { var context = new AssetContext(); return(context.Assets. Where(a => a.AssetCategoryId == categoryId). Where(a => a.EmployeeId == null). ToList()); }
public static IList <Asset> GetAllByAssetType(int id) { var context = new AssetContext(); var assets = context.Assets. Where(a => a.AssetTypeId == id). Include(t => t.AssetType).ToList(); return(assets); }
public IActionResult Get() { List <AssetLocation> list; using (var ctx = new AssetContext(new DbContextOptionsBuilder <AssetContext>().Options)) { list = ctx.AssetLocations.Where(o => o.ClientId == User.Identity.GetSubjectId()).ToList(); } return(new JsonResult(list)); }
public static async Task <Asset_Category> GetAsset_CategoryBy(Expression <Func <Asset_Category, bool> > predicate) { Asset_Category assetCategory; using (var context = new AssetContext()) { assetCategory = await context.Asset_Category.FirstOrDefaultAsync(predicate); } return(assetCategory); }
void IAssetGroup.Initialize(AssetContext context) { foreach (var asset in context) { if (asset is TAsset found) { Add(found); } } }
public AssetController(AssetContext context) { _context = context; if (_context.AssetItems.Count() == 0) { //_context.AssetItems.Add(new AssetItem { Name = "Asset1"}); _context.SaveChanges(); } }
/// <summary> /// Returns a list of all asset types from the "AssetType" table within the database. /// </summary> /// <returns>List of AssetType objects.</returns> public static List <AssetType> GetAllAssetTypes() { var context = new AssetContext(); //Declares the database context. //Generates a list of all records from the database table. var assetTypes = (from assetType in context.AssetTypes select assetType).ToList(); return(assetTypes); //Returns the list of AssetType objects. }
public static async Task <RMD_Asset_Header> GetRmd_Asset_HeaderBy(Expression <Func <RMD_Asset_Header, bool> > predicate) { RMD_Asset_Header rmdAssetHeader; using (var context = new AssetContext()) { rmdAssetHeader = await context.RMD_Asset_Header.FirstOrDefaultAsync(predicate); } return(rmdAssetHeader); }
public static async Task <IList <RMD_Asset_Header> > GetRmd_Asset_Header(Expression <Func <RMD_Asset_Header, bool> > predicate) { IList <RMD_Asset_Header> rmdAssetHeaders; using (var context = new AssetContext()) { rmdAssetHeaders = await context.RMD_Asset_Header.Where(predicate).ToListAsync(); } return(rmdAssetHeaders); }
public static async Task <IList <Asset_Category> > GetAsset_Category(Expression <Func <Asset_Category, bool> > predicate) { IList <Asset_Category> assetCategories; using (var context = new AssetContext()) { assetCategories = await context.Asset_Category.Where(predicate).ToListAsync(); } return(assetCategories); }
public cSpriteRenderer(string texture_name, MyIntRect texture_rect, AssetContext assets) : base() { this.sprite = new Sprite(assets.GetTexture(texture_name)); this.sprite.TextureRect = texture_rect.AsSfmlIntRect(); //this.sprite.Scale = new Vector2f(0.5f, 0.5f); //this.sprite.Rotation = (float)cAppMath.RadianToDegress(this.orientation); this.sprite.Origin = new Vector2f(texture_rect.Width / 2.0f, texture_rect.Height / 2.0f); }
public MyAsset Get(int assetId) { using (var context = new AssetContext()) { var selectedAsset = context.MyAssets.Include(a => a.MyConfigs).Single(a => a.Id == assetId); selectedAsset.MyConfigs = selectedAsset.MyConfigs .Where(c => c.InstanceNumber == selectedAsset.InstanceValue) .ToList(); return(selectedAsset); } }
/// <summary> /// Returns all items from the table "Assets" in the database. /// </summary> /// <returns>List of Asset objects generated from records in the database.</returns> public static List <Asset> GetAllAssets() { var context = new AssetContext(); //Creates a list of all records within "Asset" table, and also includes the "AssetType" navigation object. var assets = (from asset in context.Assets orderby asset.TagNumber select asset).Include(t => t.AssetType).ToList(); return(assets); //Returns the list of "Asset" objects. }
public static async Task <IList <RMD_Asset_Header> > GetRmd_Asset_Header() { IList <RMD_Asset_Header> rmdAssetHeaders; using (var context = new AssetContext()) { rmdAssetHeaders = await context.RMD_Asset_Header.ToListAsync(); } return(rmdAssetHeaders); }
// get all asset types as kvps public static IList GetAsKeyValuePairs() { var context = new AssetContext(); var types = context.AssetTypes.Select(t => new { Value = t.Id, Text = t.Name }).ToList(); return(types); }
public static IList GetAsKeyValuePairs() { var context = new AssetContext(); var assettypes = context.AssetTypes.Select(a => new { Key = a.Id, Value = a.Name }).ToList(); return(assettypes); }
public async Task DeleteAssetAsync(int assetId) { var context = new AssetContext(); var asset = new Asset { Id = assetId }; context.Assets.Attach(asset); context.Entry(asset).State = EntityState.Deleted; await context.SaveChangesAsync(); }
public AssetsController(AssetContext context) { _context = context; if (_context.Assets.Any()) { return; } AssetSeed.InitData(context); }
public static IEnumerable <AssetCategory> GetAll() { // The following line of code is to be un-commented if there's no Entity Framework // (The EF usage then should naturally be commented out). // var categories = LoadTestData(); var context = new AssetContext(); var categories = context.AssetCategories.ToList(); return(categories); }
//For dropdown public static IList GetAsKeyValuePairs() { var context = new AssetContext(); var types = context.AssetTypes.Select(aT => new { Value = aT.Id, //Dropdown display value Text = aT.Name //Dropdown display text }).ToList(); return(types); }