public IHttpActionResult GetCat(int id) { var prodlist = new List <ProductModel>(); using (var context = new StoreEntities()) { var prods = context.Products.Where(p => p.CategoryID == id).ToList(); foreach (var p in prods) { var prod = new ProductModel { ID = p.ID, Name = p.Name, Price = p.Price, Desc = p.Desc, Created_at = p.Created_at, Udated_at = p.Udated_at, TagName = p.TagName }; prodlist.Add(prod); } } return(Ok(prodlist)); }
public List <LocationsWithProductDto> GetInternalAndExternalLocationsWithProduct(int productId = 0, int locationId = 0) { List <LocationsWithProductDto> items; using (var ctx = new StoreEntities()) { var query = (from il in ctx.ProductLocations join i in ctx.Products on il.ProductId equals i.Id join l in ctx.Locations on il.LocationId equals l.Id select new LocationsWithProductDto { ProductId = il.ProductId, ProductName = i.Name, LocationId = il.LocationId, LocationDescription = l.Description, QuantityOnHand = il.OnHand }); if (productId > 0) { query = query.Where(x => x.ProductId == productId); } if (locationId > 0) { query = query.Where(x => x.LocationId == locationId); } items = query.ToList(); } return(items); }
public static ProductStore GetInventoryItem(int storeId, int productId) { StoreEntities db = new StoreEntities(); ProductStore productStore = db.ProductStores.Where(ps => ps.ProductId == productId && ps.StoreId == storeId).FirstOrDefault(); return(productStore); }
// GET api/musicalbum/5 public MusicAlbum Get(int id) { MusicAlbum musicAlbum = null; using (var ctx = new StoreEntities()) { var albumRaw = (from album in ctx.Albums where album.AlbumId == id join artist in ctx.Artists on album.ArtistId equals artist.ArtistId join genre in ctx.Genres on album.GenreId equals genre.GenreId select new { album, artist, genre }).SingleOrDefault(); if (albumRaw != null) { musicAlbum = new MusicAlbum { Id = albumRaw.album.AlbumId, Title = albumRaw.album.Title, Price = albumRaw.album.Price, Artist = new KeyValuePair <int, string>(albumRaw.artist.ArtistId, albumRaw.artist.Name), Genre = new KeyValuePair <int, string>(albumRaw.genre.GenreId, albumRaw.genre.Name) }; } } return(musicAlbum); }
public static int GetProIdByName(string proName) { using (StoreEntities s = new StoreEntities()) { var pro = s.Products.Where(x => x.proName == proName).FirstOrDefault(); return(pro.productID); } }
public static OrderModel GetOrderModel(int orderID) { using (StoreEntities s = new StoreEntities()) { var dbOrd = s.Orders.Where(x => x.orderID == orderID).FirstOrDefault(); return(ConvertToModel(dbOrd)); } }
public List <TransferDto> GetTransfers() { using (var ctx = new StoreEntities()) { var transferItems = ctx.Transfers.Include("Direction").Include("Location").Include("Inventory").ToList(); return(AutoMapper.Mapper.Map <List <TransferDto> >(transferItems)); } }
public static List <OrderDetModel> GetOrderDetbyEmpModelList(int empID) { using (StoreEntities s = new StoreEntities()) { var dbList = s.OrderDetails.Where(x => x.Employees.employeeID == empID).ToList(); return(ConvertToModelList(dbList)); } }
public static List <SubCateModel> GetSubCateModelList(int cateID) { using (StoreEntities s = new StoreEntities()) { var dbList = s.SubCate.Where(x => x.cateID == cateID).ToList(); return(ConvertToModelList(dbList)); } }
public static CustomerModel GetCustomerModel(int customerID) { using (StoreEntities s = new StoreEntities()) { var dbCus = s.Customers.Where(x => x.customerID == customerID).FirstOrDefault(); return(ConvertToModel(dbCus)); } }
public static PaymentModel GetPaymentModel(int paymentID) { using (StoreEntities s = new StoreEntities()) { var dbPay = s.Payment.Where(x => x.paymentID == paymentID).FirstOrDefault(); return(ConvertToModel(dbPay)); } }
public static List <PaymentModel> GetPaymentModelList() { using (StoreEntities s = new StoreEntities()) { var dbList = s.Payment.ToList(); return(ConvertToModelList(dbList)); } }
public static EmployeeModel GetEmployeeModel(int employeeID) { using (StoreEntities s = new StoreEntities()) { var dbEmp = s.Employees.Where(x => x.employeeID == employeeID).FirstOrDefault(); return(ConvertToModel(dbEmp)); } }
public static List <ProductModel> GetProductbySubCateModelList(int subCateID) { using (StoreEntities s = new StoreEntities()) { var dbList = s.Products.Where(x => x.subCateID == subCateID).ToList(); return(ConvertToModelList(dbList)); } }
public static ProductModel GetProductModel(int productID) { using (StoreEntities s = new StoreEntities()) { var dbPro = s.Products.Where(x => x.productID == productID).FirstOrDefault(); return(ConvertToModel(dbPro)); } }
public static List <RegionModel> GetRegionModelList(int cityID) { using (StoreEntities s = new StoreEntities()) { var dbList = s.Region.Where(x => x.cityID == cityID).ToList(); return(ConvertToModelList(dbList)); } }
public static RegionModel GetRegionModel(int regionID) { using (StoreEntities s = new StoreEntities()) { var dbReg = s.Region.Where(x => x.regionID == regionID).FirstOrDefault(); return(ConvertToModel(dbReg)); } }
public static string GetCusFullNameByOrderId(int orderID) { using (StoreEntities s = new StoreEntities()) { var dbOrd = s.Orders.Where(x => x.orderID == orderID).FirstOrDefault(); return(dbOrd.Customers.cFirstName + " " + dbOrd.Customers.cLastName); } }
public static List <EmployeeModel> GetEmployeeModelList() { using (StoreEntities s = new StoreEntities()) { var dbList = s.Employees.ToList(); return(ConvertToModelList(dbList)); } }
public static List <OrderModel> GetOrderModelList(int cusID, string status) { using (StoreEntities s = new StoreEntities()) { var dbList = s.Orders.Where(x => x.orderStatus == status && x.Customers.customerID == cusID).ToList(); return(ConvertToModelList(dbList)); } }
public ActionResult Cart(StoreEntities storeEnts) { User user = (User)Session["User"]; storeEnts.GetCart(user); ViewBag.ListType = "Games in your Cart: "; return(View("Index", storeEnts)); }
protected void dlUnits_ItemCommand(object source, DataListCommandEventArgs e) { int id = int.Parse(e.CommandArgument.ToString()); TaobaoTesting.StoreEntities db = new StoreEntities(); db.Units.DeleteObject(db.Units.Single(x => x.ID.Equals(id))); db.SaveChanges(); BindUnits(); }
public static void DeleteInventoryItem(int storeId, int productId) { StoreEntities db = new StoreEntities(); ProductStore productStore = db.ProductStores.Where(ps => ps.ProductId == productId && ps.StoreId == storeId).FirstOrDefault(); db.ProductStores.Remove(productStore); db.SaveChanges(); }
public static string GetCustomerFullName(int customerID) { using (StoreEntities s = new StoreEntities()) { var cus = s.Customers.Where(x => x.customerID == customerID).FirstOrDefault(); return(cus.cFirstName + " " + cus.cLastName); } }
public static List <OrderDetModel> GetOrderDetModelList(int ordID) { using (StoreEntities s = new StoreEntities()) { var dbList = s.OrderDetails.Where(x => x.orderID == ordID).ToList(); return(ConvertToModelList(dbList)); } }
public static List <CustomerModel> GetCustomerModelList() { using (StoreEntities s = new StoreEntities()) { var dbList = s.Customers.ToList(); return(ConvertToModelList(dbList)); } }
public static SubCateModel GetSubCateModel(int subCateID) { using (StoreEntities s = new StoreEntities()) { var dbSub = s.SubCate.Where(x => x.subCateID == subCateID).FirstOrDefault(); return(ConvertToModel(dbSub)); } }
// GET api/musicartist public IEnumerable <KeyValuePair <int, string> > Get() { using (var ctx = new StoreEntities()) { var artistsRaw = ctx.Artists.Select(q => new { q.Name, q.ArtistId }).ToList(); var artists = artistsRaw.Select(q => new KeyValuePair <int, string>(q.ArtistId, q.Name)); return(artists); } }
// GET api/musicgenre public IEnumerable <KeyValuePair <int, string> > Get() { using (var ctx = new StoreEntities()) { var genresRaw = ctx.Genres.Select(q => new { q.Name, q.GenreId }).ToList(); var genres = genresRaw.Select(q => new KeyValuePair <int, string>(q.GenreId, q.Name)); return(genres); } }
public ActionResult WishList(StoreEntities storeEnts) { if (Request.IsAuthenticated) { User user = (User)Session["User"]; storeEnts.GetWishlist(user); } ViewBag.ListType = "Games in your Wishlist: "; return(View("Index", storeEnts)); }
public ActionResult BuyCart(StoreEntities storeEnts) { User user = (User)Session["User"]; //Logic to actually pay for something //TODO: Add the cart to owned games user.Cart.Clear(); return(RedirectToAction("Index")); }
protected void btnAddUnit_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUnitName.Text.Trim())) { TaobaoTesting.StoreEntities db = new StoreEntities(); db.Units.AddObject(new Unit() { UnitName = txtUnitName.Text.Trim() }); txtUnitName.Text = ""; db.SaveChanges(); BindUnits(); } }
public StoreEntities Init() { return dbContext ?? (dbContext = new StoreEntities()); }
private void BindUnits() { TaobaoTesting.StoreEntities db = new StoreEntities(); this.dlUnits.DataSource = db.Units; this.dlUnits.DataBind(); }