public CitiesService(WideWorldImportersEntities context, IMapper mapper, ICache cache, ILog log)
 {
     _context = context;
     _mapper  = mapper;
     _cache   = cache;
     _log     = log;
 }
Ejemplo n.º 2
0
 public StockItemDTO GetStockItems(int id)
 {
     using (WideWorldImportersEntities entities = new WideWorldImportersEntities())
     {
         var StockItemInDB = entities.StockItems.FirstOrDefault(e => e.StockItemID == id);
         return(new StockItemDTO()
         {
             ColorID = StockItemInDB.ColorID,
             Barcode = StockItemInDB.Barcode,
             Brand = StockItemInDB.Brand,
             CustomFields = StockItemInDB.CustomFields,
             InternalComments = StockItemInDB.InternalComments,
             IsChillerStock = StockItemInDB.IsChillerStock,
             LastEditedBy = StockItemInDB.LastEditedBy,
             LeadTimeDays = StockItemInDB.LeadTimeDays,
             MarketingComments = StockItemInDB.MarketingComments,
             OuterPackageID = StockItemInDB.OuterPackageID,
             Photo = StockItemInDB.Photo,
             QuantityPerOuter = StockItemInDB.QuantityPerOuter,
             RecommendedRetailPrice = StockItemInDB.RecommendedRetailPrice,
             SearchDetails = StockItemInDB.SearchDetails,
             Size = StockItemInDB.Size,
             StockItemID = StockItemInDB.StockItemID,
             StockItemName = StockItemInDB.StockItemName,
             SupplierID = StockItemInDB.SupplierID,
             Tags = StockItemInDB.Tags,
             TaxRate = StockItemInDB.TaxRate,
             TypicalWeightPerUnit = StockItemInDB.TypicalWeightPerUnit,
             UnitPackageID = StockItemInDB.UnitPackageID,
             UnitPrice = StockItemInDB.UnitPrice,
             ValidFrom = StockItemInDB.ValidFrom,
             ValidTo = StockItemInDB.ValidTo
         });
     }
 }
Ejemplo n.º 3
0
        // GET api/<controller>/5
        public IEnumerable <StockItem> Get()
        {
            var context    = new WideWorldImportersEntities();
            var query      = from s in context.StockItems select s;
            var stockItems = query.ToArray <StockItem>();

            return(stockItems);
        }
Ejemplo n.º 4
0
 public StockItem DeleteStockItem(int id)
 {
     using (WideWorldImportersEntities entities = new WideWorldImportersEntities())
     {
         var StockItemInDB = entities.StockItems.FirstOrDefault(e => e.StockItemID == id);
         return(entities.StockItems.Remove(StockItemInDB));
     }
 }
Ejemplo n.º 5
0
 public OrderLinesBll(string @connectionString)
 {
     try
     {
         _DbModelEntities = new WideWorldImportersEntities(@connectionString);
     }
     catch (Exception err)
     {
         Console.Out.WriteLine(err);
     }
 }
Ejemplo n.º 6
0
        public AddUpdateItemResponse UpdatestockItem(StockItemDTO item)
        {
            try
            {
                using (WideWorldImportersEntities entities = new WideWorldImportersEntities())
                {
                    var originalItem = entities.StockItems.FirstOrDefault(s => s.StockItemID == item.StockItemID);

                    originalItem.Barcode                = item.Barcode;
                    originalItem.Brand                  = item.Brand;
                    originalItem.ColorID                = item.ColorID;
                    originalItem.CustomFields           = item.CustomFields;
                    originalItem.InternalComments       = item.InternalComments;
                    originalItem.IsChillerStock         = item.IsChillerStock;
                    originalItem.LastEditedBy           = item.LastEditedBy;
                    originalItem.LeadTimeDays           = item.LeadTimeDays;
                    originalItem.MarketingComments      = item.MarketingComments;
                    originalItem.OuterPackageID         = item.OuterPackageID;
                    originalItem.Photo                  = item.Photo;
                    originalItem.QuantityPerOuter       = item.QuantityPerOuter;
                    originalItem.RecommendedRetailPrice = item.RecommendedRetailPrice;
                    originalItem.SearchDetails          = item.SearchDetails;
                    originalItem.Size                 = item.Size;
                    originalItem.StockItemName        = item.StockItemName;
                    originalItem.SupplierID           = item.SupplierID;
                    originalItem.Tags                 = item.Tags;
                    originalItem.TaxRate              = item.TaxRate;
                    originalItem.TypicalWeightPerUnit = item.TypicalWeightPerUnit;
                    originalItem.UnitPackageID        = item.UnitPackageID;
                    originalItem.UnitPrice            = item.UnitPrice;
                    originalItem.ValidFrom            = item.ValidFrom;
                    originalItem.ValidTo              = item.ValidTo;

                    //entities.Entry(originalItem).State = System.Data.Entity.EntityState.Modified;
                    entities.SaveChanges();

                    return(new AddUpdateItemResponse()
                    {
                        ItemId = originalItem.StockItemID,
                        ErrorMessage = "",
                        Success = true
                    });
                }
            }
            catch (Exception ex)
            {
                return(new AddUpdateItemResponse()
                {
                    ItemId = item.StockItemID,
                    ErrorMessage = ex.ToString(),
                    Success = false
                });
            }
        }
Ejemplo n.º 7
0
        public AddItemResponse CreateStockItem(StockItem NewstockItem)
        {
            try
            {
                using (WideWorldImportersEntities entities = new WideWorldImportersEntities())
                {
                    var NewItem = new StockItem()
                    {
                        ColorID                = NewstockItem.ColorID,
                        Barcode                = NewstockItem.Barcode,
                        Brand                  = NewstockItem.Brand,
                        CustomFields           = NewstockItem.CustomFields,
                        InternalComments       = NewstockItem.InternalComments,
                        IsChillerStock         = NewstockItem.IsChillerStock,
                        LastEditedBy           = NewstockItem.LastEditedBy,
                        LeadTimeDays           = NewstockItem.LeadTimeDays,
                        MarketingComments      = NewstockItem.MarketingComments,
                        OuterPackageID         = NewstockItem.OuterPackageID,
                        Photo                  = NewstockItem.Photo,
                        QuantityPerOuter       = NewstockItem.QuantityPerOuter,
                        RecommendedRetailPrice = NewstockItem.RecommendedRetailPrice,
                        SearchDetails          = NewstockItem.SearchDetails,
                        Size                 = NewstockItem.Size,
                        StockItemID          = NewstockItem.StockItemID,
                        StockItemName        = NewstockItem.StockItemName,
                        SupplierID           = NewstockItem.SupplierID,
                        Tags                 = NewstockItem.Tags,
                        TaxRate              = NewstockItem.TaxRate,
                        TypicalWeightPerUnit = NewstockItem.TypicalWeightPerUnit,
                        UnitPackageID        = NewstockItem.UnitPackageID,
                        UnitPrice            = NewstockItem.UnitPrice,
                        ValidFrom            = NewstockItem.ValidFrom,
                        ValidTo              = NewstockItem.ValidTo
                    };

                    return(new AddItemResponse()
                    {
                        ItemId = NewstockItem.StockItemID,
                        ErrorMessage = "",
                        Success = true
                    });
                }
            }
            catch (Exception ex)
            {
                return(new AddItemResponse()
                {
                    ItemId = NewstockItem.StockItemID,
                    ErrorMessage = ex.ToString(),
                    Success = false
                });
            }
        }
Ejemplo n.º 8
0
        public IEnumerable <StockItemDTO> GetStockItems()
        {
            using (WideWorldImportersEntities entities = new WideWorldImportersEntities())
            {
                //Retrieving all items from  the database
                var StockItemsFromDB = entities.StockItems.ToList();

                //filling the retirieved item into a DTO list
                var ListOfStockItemsDTO = new List <StockItemDTO>();
                foreach (var stockItem in StockItemsFromDB)
                {
                    ListOfStockItemsDTO.Add(new StockItemDTO()
                    {
                        ColorID                = stockItem.ColorID,
                        Barcode                = stockItem.Barcode,
                        Brand                  = stockItem.Brand,
                        CustomFields           = stockItem.CustomFields,
                        InternalComments       = stockItem.InternalComments,
                        IsChillerStock         = stockItem.IsChillerStock,
                        LastEditedBy           = stockItem.LastEditedBy,
                        LeadTimeDays           = stockItem.LeadTimeDays,
                        MarketingComments      = stockItem.MarketingComments,
                        OuterPackageID         = stockItem.OuterPackageID,
                        Photo                  = stockItem.Photo,
                        QuantityPerOuter       = stockItem.QuantityPerOuter,
                        RecommendedRetailPrice = stockItem.RecommendedRetailPrice,
                        SearchDetails          = stockItem.SearchDetails,
                        Size                 = stockItem.Size,
                        StockItemID          = stockItem.StockItemID,
                        StockItemName        = stockItem.StockItemName,
                        SupplierID           = stockItem.SupplierID,
                        Tags                 = stockItem.Tags,
                        TaxRate              = stockItem.TaxRate,
                        TypicalWeightPerUnit = stockItem.TypicalWeightPerUnit,
                        UnitPackageID        = stockItem.UnitPackageID,
                        UnitPrice            = stockItem.UnitPrice,
                        ValidFrom            = stockItem.ValidFrom,
                        ValidTo              = stockItem.ValidTo
                    });
                }

                return(ListOfStockItemsDTO);
            }
        }
Ejemplo n.º 9
0
        public GetStateProvincesResponse GetStateProvinces(GetStateProvincesRequest request)
        {
            XmlConfigurator.Configure();
            var log = LogManager.GetLogger(typeof(StateProvincesService));

            log.Info("GetStateProvinces started");

            var provinces = new List <entities.StateProvince>();

            var useCache = bool.Parse(ConfigurationManager.AppSettings["UseCache"]);

            if (useCache == false || _StateProvinces == null)
            {
                var stopwatch = Stopwatch.StartNew();
                var context   = new WideWorldImportersEntities();
                foreach (var province in context.StateProvinces)
                {
                    provinces.Add(new entities.StateProvince
                    {
                        CountryIsoCode    = province.Country.IsoAlpha3Code,
                        StateProvinceCode = province.StateProvinceCode,
                        StateProvinceName = province.StateProvinceName
                    });
                }
                log.Info("GetStateProvinces data load took: " + stopwatch.ElapsedMilliseconds + "ms");
                if (useCache)
                {
                    _StateProvinces = provinces;
                }
            }

            var response = new GetStateProvincesResponse
            {
                StateProvinces = useCache ? _StateProvinces : provinces
            };

            log.Info("GetStateProvinces returning: " + response.StateProvinces.Count() + " provinces; using cache: " + useCache);
            return(response);
        }
Ejemplo n.º 10
0
        public async Task <List <OrderLines> > GetOrderLinesAsync()
        {
            List <OrderLines> ordersLines = null;
            string            SqlQuery    = "EXEC Sales.SP_GetOrderLines";

            try
            {
                using (_DbModelEntities = new WideWorldImportersEntities(_connectionString))
                {
                    using (var objectContext = ((IObjectContextAdapter)_DbModelEntities).ObjectContext)
                    {
                        var objectResult = await objectContext.ExecuteStoreQueryAsync <OrderLines>(SqlQuery);

                        ordersLines = objectResult.Take(10).ToList();
                    }
                }
                return(ordersLines);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 11
0
 public CustomerService(WideWorldImportersEntities db) : base(db)
 {
 }
Ejemplo n.º 12
0
 public CategoryService(WideWorldImportersEntities db) : base(db)
 {
 }
Ejemplo n.º 13
0
 public ServiceBase(WideWorldImportersEntities db)
 {
     Context = db;
 }