public ActionResult Index(int?page) { int pageIndex = PagingHelper.GetPageIndex(page); StockSearchModel q = new StockSearchModel(); IStockService ss = new StockService(Settings.Default.db); IPagedList <Stock> stocks = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; return(View(stocks)); }
public ActionResult Search([Bind(Include = "PartNr,PartNrAct,FIFOFrom,FIFOTo,QuantityFrom,QuantityTo,Wh,Position")] StockSearchModel q) { int pageIndex = 0; int.TryParse(Request.QueryString.Get("page"), out pageIndex); pageIndex = PagingHelper.GetPageIndex(pageIndex); ViewBag.Query = q; IStockService ss = new StockService(Settings.Default.db); IPagedList <Stock> stocks = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); return(View("Index", stocks)); }
// NOTE: Belongs to ManageStocks public IEnumerable <IResult> Display(StockSearchModel searched) { // NOTE: Future is a type which holds a reference to a value which will be set later. // this is necessary because we use constructor injection. The GetDetails method below only fetches // the details model upon execution of the underlying IResult. This then sets the value of the future // ConductContent can then retrieve the set value upon execution of the underlying IResult. // If you'd pass only a reference to a StockDetailModel this wouldn't work. var detailModel = new Future <StockDetailModel>(); return(this.Actions() .WithBusyIndication( busyScope => busyScope .GetDetails(searched, detailModel) .ConductContent(detailModel, this), General.DisplayStockDetails)); }
public void Export([Bind(Include = "PartNr,PartNrAct,FIFOFrom,FIFOTo,QuantityFrom,QuantityTo,Wh,Position")] StockSearchModel q) { IStockService ss = new StockService(Settings.Default.db); List <Stock> stocks = ss.Search(q).ToList(); ViewBag.Query = q; MemoryStream ms = new MemoryStream(); using (StreamWriter sw = new StreamWriter(ms, Encoding.UTF8)) { List <string> head = new List <string> { "No.", "PartNr", "FIFO", "Quantity", "Wh", "KanBanNr", "KanBanPosition" }; sw.WriteLine(string.Join(Settings.Default.csvDelimiter, head)); for (var i = 0; i < stocks.Count; i++) { List <string> ii = new List <string>(); ii.Add((i + 1).ToString()); ii.Add(stocks[i].partNr); ii.Add(stocks[i].fifo.ToString("yyyy-MM-dd HH:mm")); ii.Add(stocks[i].quantity.ToString()); ii.Add(stocks[i].wh.ToString()); ii.Add(stocks[i].Part.kanbanNrs.ToString()); ii.Add(stocks[i].Part.kanbanPosition.ToString()); sw.WriteLine(string.Join(Settings.Default.csvDelimiter, ii.ToArray())); } //sw.WriteLine(max); } var filename = "Stocks" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv"; var contenttype = "text/csv"; Response.Clear(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = contenttype; Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(ms.ToArray()); Response.End(); }
public static string ToSymbol(this StockSearchModel searchModel) { return searchModel.Symbol; }
public static IActionBuilder GetDetails(this IActionBuilder builder, StockSearchModel searchModel, IFutureValueSetter <StockDetailModel> detailModel) { return(builder.Execute <IGetStockDetails>(new { symbol = searchModel.ToSymbol(), detailModel })); }