Exemple #1
0
        public void Insert(Article article)
        {
            using (var context = new DataAccess.SuperZapatosContext())
            {
                var entity = new DataAccess.Article
                {
                    Description    = article.Description,
                    Name           = article.Name,
                    Price          = article.Price,
                    StoreId        = article.StoreId,
                    Total_In_Shelf = article.Total_In_Shelf,
                    Total_In_Vault = article.Total_In_Vault
                };

                context.Articles.Add(entity);
                context.SaveChanges();
            }
        }
Exemple #2
0
        public IEnumerable <Article> List()
        {
            using (var context = new DataAccess.SuperZapatosContext())
            {
                var articles = context.Articles;

                return(articles.ToArray().Select(
                           r => new Article
                {
                    Description = r.Description,
                    Id = r.Id,
                    Name = r.Name,
                    Price = r.Price,
                    StoreId = r.StoreId,
                    Total_In_Shelf = r.Total_In_Shelf,
                    Total_In_Vault = r.Total_In_Vault
                }));
            }
        }
Exemple #3
0
        public Article GetById(int id)
        {
            using (var context = new DataAccess.SuperZapatosContext())
            {
                var entity = context.Articles.Where(r => r.Id == id).FirstOrDefault();

                var article = new Article
                {
                    Description    = entity.Description,
                    Id             = entity.Id,
                    Name           = entity.Name,
                    Price          = entity.Price,
                    StoreId        = entity.StoreId,
                    Total_In_Shelf = entity.Total_In_Shelf,
                    Total_In_Vault = entity.Total_In_Vault
                };

                return(article);
            }
        }
Exemple #4
0
        public IEnumerable <Article> ListByStore(int storeId)
        {
            using (var context = new DataAccess.SuperZapatosContext())
            {
                //context.Configuration.LazyLoadingEnabled = true;

                var store = context.Stores.Where(r => r.Id == storeId).Single();

                var articles = context.Articles.Where(r => r.StoreId == storeId);

                return(articles.ToArray().Select(
                           r => new Article
                {
                    Description = r.Description,
                    Id = r.Id,
                    Name = r.Name,
                    Price = r.Price,
                    StoreId = r.StoreId,
                    Total_In_Shelf = r.Total_In_Shelf,
                    Total_In_Vault = r.Total_In_Vault
                }));
            }
        }