예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        // 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);
        }
예제 #5
0
 public static int GetProIdByName(string proName)
 {
     using (StoreEntities s = new StoreEntities()) {
         var pro = s.Products.Where(x => x.proName == proName).FirstOrDefault();
         return(pro.productID);
     }
 }
예제 #6
0
        public static OrderModel GetOrderModel(int orderID)
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbOrd = s.Orders.Where(x => x.orderID == orderID).FirstOrDefault();

                return(ConvertToModel(dbOrd));
            }
        }
예제 #7
0
 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));
     }
 }
예제 #8
0
        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));
            }
        }
예제 #9
0
        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));
            }
        }
예제 #10
0
        public static CustomerModel GetCustomerModel(int customerID)
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbCus = s.Customers.Where(x => x.customerID == customerID).FirstOrDefault();

                return(ConvertToModel(dbCus));
            }
        }
예제 #11
0
        public static PaymentModel GetPaymentModel(int paymentID)
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbPay = s.Payment.Where(x => x.paymentID == paymentID).FirstOrDefault();

                return(ConvertToModel(dbPay));
            }
        }
예제 #12
0
        public static List <PaymentModel> GetPaymentModelList()
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbList = s.Payment.ToList();

                return(ConvertToModelList(dbList));
            }
        }
예제 #13
0
        public static EmployeeModel GetEmployeeModel(int employeeID)
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbEmp = s.Employees.Where(x => x.employeeID == employeeID).FirstOrDefault();

                return(ConvertToModel(dbEmp));
            }
        }
예제 #14
0
        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));
            }
        }
예제 #15
0
        public static ProductModel GetProductModel(int productID)
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbPro = s.Products.Where(x => x.productID == productID).FirstOrDefault();

                return(ConvertToModel(dbPro));
            }
        }
예제 #16
0
        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));
            }
        }
예제 #17
0
        public static RegionModel GetRegionModel(int regionID)
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbReg = s.Region.Where(x => x.regionID == regionID).FirstOrDefault();

                return(ConvertToModel(dbReg));
            }
        }
예제 #18
0
        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);
            }
        }
예제 #19
0
        public static List <EmployeeModel> GetEmployeeModelList()
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbList = s.Employees.ToList();

                return(ConvertToModelList(dbList));
            }
        }
예제 #20
0
        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));
            }
        }
예제 #21
0
        public ActionResult Cart(StoreEntities storeEnts)
        {
            User user = (User)Session["User"];

            storeEnts.GetCart(user);
            ViewBag.ListType = "Games in your Cart: ";
            return(View("Index", storeEnts));
        }
예제 #22
0
파일: UnitList.aspx.cs 프로젝트: eavia/tts
 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();
 }
예제 #23
0
        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();
        }
예제 #24
0
        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);
            }
        }
예제 #25
0
        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));
            }
        }
예제 #26
0
        public static List <CustomerModel> GetCustomerModelList()
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbList = s.Customers.ToList();

                return(ConvertToModelList(dbList));
            }
        }
예제 #27
0
        public static SubCateModel GetSubCateModel(int subCateID)
        {
            using (StoreEntities s = new StoreEntities()) {
                var dbSub = s.SubCate.Where(x => x.subCateID == subCateID).FirstOrDefault();

                return(ConvertToModel(dbSub));
            }
        }
예제 #28
0
 // 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);
     }
 }
예제 #29
0
 // 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);
     }
 }
예제 #30
0
 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));
 }
예제 #31
0
        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"));
        }
예제 #32
0
파일: UnitList.aspx.cs 프로젝트: eavia/tts
 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());
 }
예제 #34
0
파일: UnitList.aspx.cs 프로젝트: eavia/tts
 private void BindUnits()
 {
     TaobaoTesting.StoreEntities db = new StoreEntities();
     this.dlUnits.DataSource = db.Units;
     this.dlUnits.DataBind();
 }