public IQueryable <ExchangerateDto> GetPartExchangerates(DateTime date1, DateTime date2)
        {
            //проверка на присутствие котировок за определенную дату
            bool absent       = false;
            var  exchangerate = db.ExchangerateList;

            for (var currentDay = date1; currentDay <= date2; currentDay = currentDay.AddDays(1))
            {
                foreach (var p in exchangerate)
                {
                    if (currentDay == p.Date)
                    {
                        absent = true;
                        break;
                    }
                }
                if (!absent)
                {
                    WorkerDB.AddNewExchangerate(currentDay);
                }
                absent = false;
            }


            return(db.ExchangerateList.Include(b => b.Base)
                   .Where(b => DbFunctions.TruncateTime(b.Date) >= DbFunctions.TruncateTime(date1) &&
                          DbFunctions.TruncateTime(b.Date) <= DbFunctions.TruncateTime(date2)).Select(AsExchangerateDto));
        }
示例#2
0
 public UC()
 {
     InitializeComponent();
     db = new ProductContext();
     db.Products.Load();
     productsGrid.ItemsSource = null;
     productsGrid.ItemsSource = db.Products.Local.ToBindingList();  //привязка к кэшу
     WorkerDB.DeleteAllRows("Products");
 }
示例#3
0
        private static void EndDate_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var current = d as ApplicationViewModel;

            if (current != null)
            {
                WorkerDB.AddNewProducts(current.StartDate, current.EndDate);
            }
        }
示例#4
0
 public IHttpActionResult Get()
 {
     try
     {
         return(Ok(WorkerDB.GetAllWorkers()));
     }
     catch (Exception ex)
     {
         return(BadRequest("could not get all the Workers ! \n  --" + ex.Message));
     }
 }
示例#5
0
        /// <summary>
        /// Click method.
        /// </summary>
        private void ClickMethod()
        {
            WorkerDB.AddNewProducts(StartDate, EndDate);
            MessageBox.Show("This is click command.");


            //MainWindow mw = new MainWindow();
            //UC ui = new UC();
            //ui.DataContext =
            //G1.Children.Add(ui);
            //Grid.SetRow(ui, 2);
        }
示例#6
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        public ApplicationViewModel()
        {
            // Добавление нового значения в таблицу Products.
            //WorkerDB.AddNewProduct("http://api.fixer.io/latest");

            //Удаление всех строк из таблице.
            WorkerDB.DeleteAllRows("Products");
            //var date1 = new DateTime(2000,01,01);
            //var date2 = new DateTime(2000,01,05);
            ClickCommand = new Command(arg => ClickMethod());

            //WorkerDB.AddNewProducts(StartDate, EndDate);
        }
示例#7
0
        public IHttpActionResult Put(Worker Worker2Update)
        {
            try
            {
                int res = WorkerDB.UpdateWorker(Worker2Update);
                if (res == 1)
                {
                    return(Ok());
                }
                return(Content(HttpStatusCode.NotModified, $"Worker with id {Worker2Update.WorkerID} exsits but could not be modified!!!"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));

                throw;
            }
        }
示例#8
0
        public IHttpActionResult Post([FromBody] Worker val)
        {
            try
            {
                Worker res = WorkerDB.InsertWorkerToDb(val);
                if (res == null)
                {
                    return(Content(HttpStatusCode.BadRequest, $"could not insert Worker {val.ToString()} or already exists!"));
                }
                return(Created(new Uri(Url.Link("GetWorkerById", new { id = res.WorkerID })), res));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));

                throw;
            }
        }
示例#9
0
        static void Main(string[] args)
        {
            var config = new HttpSelfHostConfiguration("http://localhost:8080");

            config.MapHttpAttributeRoutes();

            //config.Routes.MapHttpRoute(
            //    "API Default", "api/{controller}/{id}",
            //    new { id = RouteParameter.Optional });


            //очистить таблицу
            //WorkerDB.TableClear("Exchangerates");

            //загрузка котировок текущего месяца
            WorkerDB.AddExchangeratesCurrentMounth();

            using (HttpSelfHostServer server = new HttpSelfHostServer(config))
            {
                server.OpenAsync().Wait();
                Console.WriteLine("Press Enter to quit.");
                Console.ReadLine();
            }
        }
示例#10
0
 public Worker Get(string email, string password)
 {
     return(WorkerDB.GetWorkerByEmailAndPassword(email, password));
 }