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)); }
public UC() { InitializeComponent(); db = new ProductContext(); db.Products.Load(); productsGrid.ItemsSource = null; productsGrid.ItemsSource = db.Products.Local.ToBindingList(); //привязка к кэшу WorkerDB.DeleteAllRows("Products"); }
private static void EndDate_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) { var current = d as ApplicationViewModel; if (current != null) { WorkerDB.AddNewProducts(current.StartDate, current.EndDate); } }
public IHttpActionResult Get() { try { return(Ok(WorkerDB.GetAllWorkers())); } catch (Exception ex) { return(BadRequest("could not get all the Workers ! \n --" + ex.Message)); } }
/// <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); }
/// <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); }
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; } }
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; } }
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(); } }
public Worker Get(string email, string password) { return(WorkerDB.GetWorkerByEmailAndPassword(email, password)); }