コード例 #1
0
        public ActionResult Index(int?page)
        {
            int             pageIndex = PagingHelper.GetPageIndex(page);
            PartSearchModel q         = new PartSearchModel();
            IPartService    ps        = new PartService(Settings.Default.db);

            IPagedList <Part> parts = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetPartTypeList(null);

            return(View(parts));
        }
コード例 #2
0
        public ActionResult Search([Bind(Include = "PartNr, PartType")] PartSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            IPartService ps = new PartService(Settings.Default.db);

            IPagedList <Part> parts = ps.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            SetPartTypeList(q.PartType);
            return(View("Index", parts));
        }
コード例 #3
0
        public async Task <List <PartDTO> > Search(PartSearchCriteria searchCriteria = null)
        {
            List <PartDTO> parts = new List <PartDTO>();

            try
            {
                parts = await _partService.Search(searchCriteria);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Search Error (controller): " + ex.Message);
                Console.WriteLine(ex.StackTrace);
                //Console.Write(ex.ToString());
            }

            return((parts == null) ? new List <PartDTO>() : parts);
        }
コード例 #4
0
        public void Export([Bind(Include = "PartNr, PartType")] PartSearchModel q)
        {
            IPartService ps = new PartService(Settings.Default.db);

            List <Part> parts = ps.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", "PartType", "PartDesc", "PartStatus", "MOQ",
                    "SPQ", "Action"
                };
                sw.WriteLine(string.Join(Settings.Default.csvDelimiter, head));
                for (var i = 0; i < parts.Count; i++)
                {
                    List <string> ii = new List <string>();
                    ii.Add((i + 1).ToString());
                    ii.Add(parts[i].partNr);
                    ii.Add(parts[i].partType.ToString());
                    ii.Add(parts[i].partDesc);
                    ii.Add(parts[i].partStatus.ToString());
                    ii.Add(parts[i].moq.ToString());
                    ii.Add(parts[i].spq.ToString());
                    ii.Add("");
                    sw.WriteLine(string.Join(Settings.Default.csvDelimiter, ii.ToArray()));
                }
                //sw.WriteLine(max);
            }
            var filename    = "Parts" + 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();
        }
コード例 #5
0
        public ActionResult Blocks(SearchBlockModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Redirect("Search/Blocks"));
            }

            IEnumerable <Category> categories = categoryRepository.Query();

            model.AllCategories = categories;

            string searchParameters = SearchHelper.ConstructSearchParameters(model);

            Debug.WriteLine(searchParameters);

            var blocks = blockService.Search(searchParameters, 20);

            ViewBag.listItems = blocks.ToList();

            return(View(model));
        }
コード例 #6
0
        public List <PartApi> Search(string searchParameters, int take = -1, int offset = 0)
        {
            var filteredSets = kockicaService.Search(searchParameters, take, offset).ToList();

            return(Mapper.Map <List <PartApi> >(filteredSets));
        }