)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » SearchController (Ia.Statistics.Wa.Controllers)

Public general use code classes and xml files that we've compiled and used over the years:

    1: using Ia.Statistics.Wa.Models;
    2: using Microsoft.AspNetCore.Mvc;
    3: using System.Diagnostics;
    4: using System.Net;
    5: using System.Text.RegularExpressions;
    6:  
    7: namespace Ia.Statistics.Wa.Controllers
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     ///
   13:     /// </summary>
   14:     /// 
   15:     /// <remarks> 
   16:     /// Copyright � 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   17:     ///
   18:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   19:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   20:     ///
   21:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   22:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   23:     /// 
   24:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   25:     /// 
   26:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   27:     /// </remarks> 
   28:     public class SearchController : Controller
   29:     {
   30:         /////////////////////////////////////////////////////////////////////////////////
   31:  
   32:         /// <summary>
   33:         ///
   34:         /// </summary>
   35:         [Route("/search")]
   36:         public IActionResult Index(string searchText)
   37:         {
   38:             if (!string.IsNullOrEmpty(searchText))
   39:             {
   40:                 var indexViewModel = new Ia.Statistics.Wa.Models.Home.IndexViewModel();
   41:  
   42:                 indexViewModel.SearchTextInput = searchText;
   43:  
   44:                 return Search(indexViewModel);
   45:             }
   46:             else return View();
   47:         }
   48:  
   49:         /////////////////////////////////////////////////////////////////////////////////
   50:  
   51:         /// <summary>
   52:         ///
   53:         /// </summary>
   54:         [HttpPost]
   55:         [Route("/search")]
   56:         public IActionResult Search(Ia.Statistics.Wa.Models.Home.IndexViewModel indexViewModel)
   57:         {
   58:             var input = indexViewModel.SearchTextInput;
   59:  
   60:             if (!string.IsNullOrEmpty(input))
   61:             {
   62:                 input = WebUtility.HtmlDecode(input);
   63:  
   64:                 Ia.Statistics.Cl.Models.Default.Search(input, out List<Ia.Statistics.Cl.Models.ProductPriceStockQuantitySold> list, out Ia.Cl.Models.Result result);
   65:  
   66:                 if (result.IsSuccessful)
   67:                 {
   68:                     if (list != null) indexViewModel.ProductPriceStockQuantitySoldList = list.OrderBy(u => u.Product.Name).ToList();
   69:                     else indexViewModel.ProductPriceStockQuantitySoldList = list.ToList();
   70:                 }
   71:                 else
   72:                 {
   73:                 }
   74:  
   75:                 indexViewModel.SearchResult = result;
   76:             }
   77:             else
   78:             {
   79:             }
   80:  
   81:             return View("Index", indexViewModel);
   82:         }
   83:  
   84:         /////////////////////////////////////////////////////////////////////////////////
   85:  
   86:         /// <summary>
   87:         ///
   88:         /// </summary>
   89:         [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
   90:         public IActionResult Error()
   91:         {
   92:             return View(new Ia.Statistics.Wa.Models.ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
   93:         }
   94:  
   95:         /////////////////////////////////////////////////////////////////////////////////
   96:         /////////////////////////////////////////////////////////////////////////////////
   97:     }
   98:  
   99:     /////////////////////////////////////////////////////////////////////////////////
  100:     /////////////////////////////////////////////////////////////////////////////////
  101: }