public FilterDateTimeWindow(FilterDateModel model) { InitializeComponent(); if (model == null) { throw new ArgumentNullException(nameof(model)); } this.Model = model; switch (model.Condition) { case TwoConditionRule.MinAndMax: case TwoConditionRule.MinOrMax: chbfewer.IsChecked = true; chbLarger.IsChecked = true; break; case TwoConditionRule.MinOnly: chbLarger.IsChecked = true; break; case TwoConditionRule.MaxOnly: chbfewer.IsChecked = true; break; } dtpLarger.SelectedDate = model.MinTime ?? DateTime.Parse($"{DateTime.Now.Year:D4}/{DateTime.Now.Month:D2}/{DateTime.Now.Day:D2} 00:00"); dtpfewer.SelectedDate = model.MaxTime ?? DateTime.Parse($"{DateTime.Now.Year:D4}/{DateTime.Now.Month:D2}/{DateTime.Now.Day:D2} 23:59:59"); rtbOr.IsChecked = model.Condition == TwoConditionRule.MinOrMax; }
public ActionResult FilterReport(FilterDateModel dateModel) { var product = _product.GetAll(); var orderReport = GetOrderReports(dateModel).ToList(); ViewBag.xLabels = product.Select(x => x.Name).ToList(); ViewBag.yValues = GetOrderReports(dateModel).Select(x => x.CountBuy).ToList(); ViewBag.y2Values = GetOrderReports(dateModel).Select(x => x.CountView).ToList(); return(PartialView("_ReportAuction", orderReport)); }
// GET: Admin/Report public ActionResult Index(FilterDateModel dateModel) { //var product = _product.GetAll(); //var orderReport = GetOrderReports(dateModel).ToList(); //ViewBag.xLabels = product.Select(x => x.Name).ToList(); //ViewBag.yValues = GetOrderReports(dateModel).Select(x => x.CountBuy).ToList(); //ViewBag.y2Values = GetOrderReports(dateModel).Select(x => x.CountView).ToList(); //return View(orderReport); return(View()); }
public static bool?Show(ref FilterDateModel fdtModel) { if (fdtModel == null) { fdtModel = new FilterDateModel(); } var window = new FilterDateTimeWindow(fdtModel); window.ShowDialog(); return(window.FilterResult); }
public async Task <IActionResult> GetReport([FromBody] FilterDateModel model) { try { var result = await _ISupervisor.GetReport(model); return(Ok(result) ); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, "Db is down")); } }
private IEnumerable <object> FilterDTRow(IEnumerable <object> rows, FilterDateModel fdtModel, Func <object, DateTime?> dtFunc) { if (fdtModel.Condition == TwoConditionRule.MinOnly) { rows = rows.Where(p => dtFunc(p) >= fdtModel.MinTime); } else if (fdtModel.Condition == TwoConditionRule.MaxOnly) { rows = rows.Where(p => dtFunc(p) <= fdtModel.MaxTime); } else if (fdtModel.Condition == TwoConditionRule.MinOrMax) { rows = rows.Where(p => dtFunc(p) <= fdtModel.MaxTime || dtFunc(p) >= fdtModel.MinTime); } else if (fdtModel.Condition == TwoConditionRule.MinAndMax) { rows = rows.Where(p => dtFunc(p) <= fdtModel.MaxTime && dtFunc(p) >= fdtModel.MinTime); } return(rows); }
public async Task <Report> GetReport(FilterDateModel model) { var invoices = await _InvoiceContext.Invoices .Where(e => e.StoreId == model.StoreId && e.CreatedDate > model.FromDate && e.CreatedDate < model.ToDate) .Include(e => e.Store) .Include(e => e.InvoiceItems) .ThenInclude(e => e.Item).ToListAsync(); var invoiceCount = invoices.Count; Report report = invoices.Select(er => new Report() { StoreName = er.Store.Name, TotalPrices = er.InvoiceItems.Sum(e => e.Item.Price * e.Quantity), InvoiceCount = invoiceCount, ItemCounts = er.InvoiceItems.Sum(e => e.Quantity) }).FirstOrDefault(); return(report); }
public static FilterDateModel GetFilterDateBeginAndEnd(object date) { DateTime dt = new DateTime(); if (date is string) { dt = Convert.ToDateTime(date); } else { dt = (DateTime)date; } DateTime startDate = new DateTime(dt.Year, dt.Month, dt.Day, 00, 00, 00); DateTime endDate = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59); FilterDateModel model = new FilterDateModel() { StartDate = startDate, EndDate = endDate }; return(model); }
public IEnumerable <OrderReport> GetOrderReports(FilterDateModel dateModel) { var listOrderDetail = from order in _order.GetAll() join orderDetail in _orderDetail.GetAll() on order.Id equals orderDetail.OrderId join product in _product.GetAll() on orderDetail.ProductId equals product.Id join user in _User.GetAll() on orderDetail.CreateBy equals user.Id where order.Status == true select new OrderReport { Id = orderDetail.Id, CreateAt = orderDetail.CreateAt, CreateBy = user.Email, OrderId = orderDetail.OrderId, ProductId = product.Name, Quantity = orderDetail.Quantity, Status = orderDetail.Status, Price = orderDetail.Price, CountBuy = product.CountBuy, CountView = product.CountView }; if (!string.IsNullOrEmpty(dateModel.NameProduct)) { listOrderDetail = listOrderDetail.Where(s => s.ProductId.ToLower().Contains(dateModel.NameProduct.ToLower())); } var date = Convert.ToDateTime(dateModel.EndDate); if (date != DateTime.MinValue) { listOrderDetail = listOrderDetail.Where(d => d.CreateAt.Date == date); } return(listOrderDetail); }
public async Task <Report> GetReport(FilterDateModel model) { return(await _IInvoiceRepo.GetReport(model)); }