public static void Update(ClientItem client, string cs)
 {
     using (var ctx = new ExchangeDataContext(cs))
     {
         var c = ctx.Clients.Single(x => x.Id == client.Id);
         c.EndDateTime = client.EndDate;
         ctx.SubmitChanges();
     }
 }
        public static void Save(ClientItem client, string cs)
        {
            using (var ctx = new ExchangeDataContext(cs))
            {
                var c = new Client
                {
                    Id            = client.Id,
                    StartDateTime = client.StartDate,
                    EndDateTime   = client.EndDate
                };

                ctx.Clients.InsertOnSubmit(c);
                ctx.SubmitChanges();
            }
        }
Example #3
0
        public static void Save(List <PriceItem> prices, string cs)
        {
            using (var ctx = new ExchangeDataContext(cs))
            {
                var list = prices.Select(priceItem => new Price
                {
                    DateUpd       = priceItem.DateUpdate,
                    CurrencyCode  = ((int)priceItem.CurrencyCode).ToString(CultureInfo.InvariantCulture),
                    CurrencyPrice = priceItem.Price,
                }).ToList();

                ctx.Prices.InsertAllOnSubmit(list);
                ctx.SubmitChanges();
            }
        }
Example #4
0
        public static void Add(ServerLogItem item, string cs)
        {
            using (var ctx = new ExchangeDataContext(cs))
            {
                var cl = new ServerLog()
                {
                    EventTypeId           = (int)item.EventType,
                    EventDate             = item.Date,
                    Data                  = item.Data,
                    ServerId              = item.ServerId,
                    AvailableClientsCount = item.AvailableClientsCount
                };

                ctx.ServerLogs.InsertOnSubmit(cl);
                ctx.SubmitChanges();
            }
        }
Example #5
0
        public static void Save(Common.OrderItem orderItem, string cs)
        {
            using (var ctx = new ExchangeDataContext(cs))
            {
                var o = new Order
                {
                    ClientId  = orderItem.ClientId,
                    PriceId   = orderItem.PriceId,
                    DealDate  = orderItem.Date,
                    DealValue = orderItem.Value
                };

                ctx.Orders.InsertOnSubmit(o);
                ctx.SubmitChanges();

                orderItem.Id = o.Id;
            }
        }
Example #6
0
        public void CreateDb(string connectionString)
        {
            using (var dc = new ExchangeDataContext(connectionString))
            {
                dc.CreateDatabase();

                var currences = new[]
                {
                    new Currency {
                        Name = "RUB", Code = "643", FullName = "Russian Rouble"
                    },
                    new Currency {
                        Name = "USD", Code = "840", FullName = "US Dollar"
                    },
                    new Currency {
                        Name = "EUR", Code = "978", FullName = "Euro"
                    },
                    new Currency {
                        Name = "CHF", Code = "756", FullName = "Swiss franc"
                    },
                    new Currency {
                        Name = "JPY", Code = "392", FullName = "Japanese Yen"
                    },
                    new Currency {
                        Name = "GBP", Code = "826", FullName = "British Pound"
                    },
                    new Currency {
                        Name = "CAD", Code = "124", FullName = "Canadian Dollar"
                    },
                    new Currency {
                        Name = "CNY", Code = "156", FullName = "Chinese yen"
                    },
                    new Currency {
                        Name = "BRL", Code = "986", FullName = "Brazilian Real"
                    }
                };

                // заполнение справочника валют
                using (var scope = new TransactionScope())
                {
                    dc.Currencies.InsertAllOnSubmit(currences);
                    dc.SubmitChanges();
                    scope.Complete();
                }

                // заполнение справочника событий
                var eventTypes = new[]
                {
                    new EventType {
                        Id = 1, Name = "Server started"
                    },
                    new EventType {
                        Id = 2, Name = "Server stopped"
                    },
                    new EventType {
                        Id = 3, Name = "Server running"
                    },
                };

                using (var scope = new TransactionScope())
                {
                    dc.EventTypes.InsertAllOnSubmit(eventTypes);
                    dc.SubmitChanges();
                    scope.Complete();
                }
            }
        }