public async Task <ActionResult> ViewContacts(AdvancedSearchViewModel viewModel)
        {
            if (viewModel.AccountID == 0)
            {
                viewModel.AccountID = this.Identity.ToAccountID();
            }
            AdvancedSearchResponse <ContactAdvancedSearchEntry> response = await advancedSearchService.ViewContactsAsync(new AdvancedSearchRequest <ContactAdvancedSearchEntry>()
            {
                SearchViewModel  = viewModel,
                AccountId        = viewModel.AccountID,
                RoleId           = this.Identity.ToRoleID(),
                RequestedBy      = this.Identity.ToUserID(),
                IsAdvancedSearch = true,
                ViewContacts     = true
            });

            Guid guid = Guid.NewGuid();

            if (response.ContactIds != null)
            {
                AddCookie("ContactsGuid", guid.ToString(), 1);
                var contactIds = response.ContactIds;
                cachingService.StoreSavedSearchContactIds(guid.ToString(), contactIds);
            }
            return(Json(new
            {
                success = true,
                response = guid.ToString()
            }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public async Task <HttpResponseMessage> RunSearch(AdvancedSearchViewModel viewModel)
        {
            if (viewModel.AccountID == 0)
            {
                viewModel.AccountID = this.AccountId;
            }
            var pageSize = ReadCookie("savedsearchpagesize");
            var limit    = 10;

            if (pageSize != null)
            {
                int.TryParse(pageSize, out limit);
            }

            AdvancedSearchResponse <ContactAdvancedSearchEntry> response = await advancedSearchService.RunSearchAsync(
                new AdvancedSearchRequest <ContactAdvancedSearchEntry>()
            {
                SearchViewModel  = viewModel,
                AccountId        = this.AccountId,
                RoleId           = this.RoleId,
                RequestedBy      = this.UserId,
                IsAdvancedSearch = true,
                Limit            = limit,
            });

            return(Request.BuildResponse(response));
        }
        public IActionResult AdvancedSearch(AdvancedSearchViewModel model)
        {
            if (ModelState.IsValid)
            {
                Search search = new Search(model, repository);
                search.Check();
                search.Filtr();
                search.Check();
                search.Filtr();
                search.Check();
                search.Filtr();
                search.Check();
                search.Filtr();
                search.Check();
                search.Filtr();

                model.UserList = search.Users;

                return(View(model));
            }
            else
            {
                return(View(model));
            }
        }
        public IActionResult AdvancedSearch()
        {
            AdvancedSearchViewModel model = new AdvancedSearchViewModel();


            return(View(model));
        }
Example #5
0
        public IActionResult Data(IDataTablesRequest requestModel, AdvancedSearchViewModel searchViewModel)
        {
            DataTablesResponse response            = _messageService.SearchApi(requestModel, searchViewModel);
            DataTablesResponse responseTransformed = DataTablesResponse.Create(requestModel, response.TotalRecords, response.TotalRecordsFiltered, response.Data);

            return(new DataTablesJsonResult(responseTransformed, true));
        }
Example #6
0
 /// <summary>
 /// Provides a  way to create the AdvancedSearchVM property
 /// </summary>
 public static void CreateAdvancedSearchVM()
 {
     if (advancedSearchVM == null)
     {
         advancedSearchVM = new AdvancedSearchViewModel();
     }
 }
        public ActionResult Get([ModelBinder(typeof(DataTablesBinder))]
                                IDataTablesRequest requestModel, AdvancedSearchViewModel searchViewModel)
        {
            IQueryable <Assets> query = DbContext.Assets;
            var totalCount            = query.Count();

            // searching and sorting
            query = SearchAssets(requestModel, searchViewModel, query);
            var filteredCount = query.Count();

            // Paging
            //query = query.Skip(requestModel.Start).Take(requestModel.Length);

            var data = query.Select(asset => new
            {
                AssetID      = asset.AssetID,
                BarCode      = asset.Barcode,
                Manufacturer = asset.Manufacturer,
                ModelNumber  = asset.ModelNumber,
                Building     = asset.Building,
                RoomNo       = asset.RoomNo,
                Quantity     = asset.Quantity
            }).ToList();

            return(Json(new DataTablesResponse
                            (requestModel.Draw, data, filteredCount, totalCount), JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> ExportToPDFFile(AdvancedSearchViewModel advancedSearchViewModel)
        {
            if (advancedSearchViewModel.AccountID == 0)
            {
                advancedSearchViewModel.AccountID = this.Identity.ToAccountID();
            }
            advancedSearchViewModel.PageNumber = 1;
            ExportSearchResponse exportResponse = await advancedSearchService.ExportSearchToPDFAsync(new ExportSearchRequest()
            {
                SearchViewModel = advancedSearchViewModel,
                FileType        = "PDF",
                DateFormat      = this.Identity.ToDateFormat(),
                TimeZone        = this.Identity.ToTimeZone()
            });

            string fileKey = Guid.NewGuid().ToString();
            bool   result  = cachingService.StoreTemporaryFile(fileKey, exportResponse.byteArray);

            Logger.Current.Informational("Did temporary file stored in cache : " + result.ToString());
            return(Json(new
            {
                success = true,
                fileKey = fileKey,
                fileName = exportResponse.FileName
            }, JsonRequestBehavior.AllowGet));
        }
Example #9
0
 //[Authorize(Roles="Role1,Role2,...")]
 public ActionResult Advance(AdvancedSearchViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(Content("Check the required Inputs marked with * !"));
     }
     return(View(model));
 }
        public AdvancedSearchView(IJiraToolWindowNavigatorViewModel parent, IPriorityService priorityService,
                                  IIssueService issueService, IProjectService projectService, ISprintService sprintService, IBoardService boardService)
        {
            InitializeComponent();

            this._viewModel = new AdvancedSearchViewModel(parent, priorityService, issueService, projectService,
                                                          sprintService, boardService);
            this.DataContext = this._viewModel;
        }
        private IQueryable <Assets> SearchAssets(IDataTablesRequest requestModel,
                                                 AdvancedSearchViewModel searchViewModel, IQueryable <Assets> query)
        {
            // Apply filters
            if (requestModel.Search.Value != string.Empty)
            {
                var value = requestModel.Search.Value.Trim();
                query = query.Where(p => p.Barcode.Contains(value) ||
                                    p.Manufacturer.Contains(value) ||
                                    p.ModelNumber.Contains(value) ||
                                    p.Building.Contains(value)
                                    );
            }

            /***** Advanced Search Starts ******/
            //if (searchViewModel.FacilitySite != Guid.Empty)
            //{
            //    query = query.Where(x => x.FacilitySiteID == searchViewModel.FacilitySite);
            //}

            if (searchViewModel.Building != null)
            {
                query = query.Where(x => x.Building == searchViewModel.Building);
            }

            if (searchViewModel.Manufacturer != null)
            {
                query = query.Where(x => x.Manufacturer == searchViewModel.Manufacturer);
            }

            if (searchViewModel.Status != null)
            {
                bool Issued = bool.Parse(searchViewModel.Status);
                query = query.Where(x => x.Issued == Issued);
            }

            /***** Advanced Search Ends ******/

            var filteredCount = query.Count();

            // Sort
            var sortedColumns = requestModel.Columns.GetSortedColumns();
            var orderByString = String.Empty;

            foreach (var column in sortedColumns)
            {
                orderByString += orderByString != String.Empty ? "," : "";
                orderByString += (column.Data) +
                                 (column.SortDirection == Column.OrderDirection.Ascendant ?
                                  " asc" : " desc");
            }

            //query = query.OrderBy(orderByString ==string.Empty ? "BarCode asc" : orderByString);

            return(query);
        }
        public AdvancedSearchPage()
        {
            this.InitializeComponent();

            if (!ViewModelBase.IsInDesignModeStatic)
            {
                ViewModel   = new AdvancedSearchViewModel();
                DataContext = ViewModel;
            }
        }
        public ActionResult AdvancedSearchList()
        {
            AdvancedSearchViewModel viewModel = new AdvancedSearchViewModel();
            short ItemsPerPage = default(short);

            short.TryParse(this.Identity.ToItemsPerPage(), out ItemsPerPage);
            ViewBag.ItemsPerPage       = ItemsPerPage;
            ViewBag.DateFormat         = this.Identity.ToDateFormat();
            ViewBag.SearchDefinitionId = 0;
            return(View("AdvancedSearchList", viewModel));
        }
Example #14
0
        public async Task <IActionResult> SearchResults(AdvancedSearchViewModel searchVm)
        {
            var results = await _bookService.GetFilteredResults(searchVm.Title, searchVm.Author, searchVm.Subject, searchVm.Year, searchVm.Inclusive);

            var booksVm    = results.Select(b => b.MapToListItemBookViewModel());
            var booksQuery = booksVm.AsQueryable();

            int pageSize = 5;

            return(View(PaginatedList <BookListViewModel> .CreateAsync(booksQuery.AsNoTracking(), 1, pageSize)));
        }
        public ActionResult AdvancedSearch()
        {
            var accountId = this.Identity.ToAccountID();
            var roleId    = this.Identity.ToRoleID();
            IList <FilterViewModel> filters         = new List <FilterViewModel>();
            FilterViewModel         filterviewmodel = new FilterViewModel();

            filterviewmodel.FieldId               = (int)ContactFields.FirstNameField;
            filterviewmodel.SearchDefinitionID    = 0;
            filterviewmodel.SearchFilterID        = 0;
            filterviewmodel.SearchQualifierTypeID = (short)SearchQualifier.Is;
            filterviewmodel.SearchText            = string.Empty;
            FilterViewModel lastNameFilter = new FilterViewModel();

            lastNameFilter.FieldId               = (int)ContactFields.LastNameField;
            lastNameFilter.SearchDefinitionID    = 0;
            lastNameFilter.SearchFilterID        = 0;
            lastNameFilter.SearchQualifierTypeID = (short)SearchQualifier.Is;
            lastNameFilter.SearchText            = string.Empty;
            filters.Add(filterviewmodel);
            filters.Add(lastNameFilter);
            IEnumerable <FieldViewModel>   searchFields = null;
            GetAdvanceSearchFieldsResponse response     = advancedSearchService.GetSearchFields(new GetAdvanceSearchFieldsRequest()
            {
                accountId = accountId,
                RoleId    = roleId
            });

            if (response.FieldsViewModel != null)
            {
                searchFields = response.FieldsViewModel;
            }
            AdvancedSearchViewModel searchViewModel = new AdvancedSearchViewModel()
            {
                SearchDefinitionName  = "",
                SearchPredicateTypeID = 1,
                SearchFilters         = filters,
                SearchFields          = searchFields
            };
            short ItemsPerPage = default(short);

            short.TryParse(this.Identity.ToItemsPerPage(), out ItemsPerPage);
            ViewBag.ItemsPerPage = ItemsPerPage;
            AddCookie("savedsearchpagesize", ItemsPerPage.ToString(), 1);
            int defaultPageNumber = 1;

            AddCookie("advancedsearchpagenumber", defaultPageNumber.ToString(), 1);
            ViewBag.EmailPermission = cachingService.CheckSendMailPermissions(accountId, roleId);
            bool gridvisible = false;

            ViewBag.grid = gridvisible;
            return(View("AddEditSearch", searchViewModel));
        }
Example #16
0
        public ActionResult AdvancedSearch(AdvancedSearchViewModel model)
        {
            //InitializeSearch(model);

            /*
             * foreach (var card in _cardService.Search(model))
             * {
             *  model.Cards.Add(new CardViewModel(card));
             * }
             */

            return(View(model));
        }
Example #17
0
        public HttpResponseMessage UpdateSearch(AdvancedSearchViewModel viewModel)
        {
            SaveAdvancedSearchResponse response = advancedSearchService.UpdateSavedSearch(
                new SaveAdvancedSearchRequest()
            {
                AdvancedSearchViewModel = viewModel,
                AccountId   = this.AccountId,
                RequestedBy = this.UserId,
                RoleId      = this.RoleId
            });

            return(Request.BuildResponse(response));
        }
        public IActionResult AdvancedSearch(AdvancedSearchViewModel ViewModel)
        {
            ViewModel.Author     = String.IsNullOrEmpty(ViewModel.Author) ? "" : ViewModel.Author;
            ViewModel.Category   = String.IsNullOrEmpty(ViewModel.Category) ? "" : ViewModel.Category;
            ViewModel.ISBN       = String.IsNullOrEmpty(ViewModel.ISBN) ? "" : ViewModel.ISBN;
            ViewModel.Language   = String.IsNullOrEmpty(ViewModel.Language) ? "" : ViewModel.Language;
            ViewModel.Publisher  = String.IsNullOrEmpty(ViewModel.Publisher) ? "" : ViewModel.Publisher;
            ViewModel.Title      = String.IsNullOrEmpty(ViewModel.Title) ? "" : ViewModel.Title;
            ViewModel.Translator = String.IsNullOrEmpty(ViewModel.Translator) ? "" : ViewModel.Translator;
            var Books = _repository.GetBooks(ViewModel.Title, ViewModel.ISBN,
                                             ViewModel.Language, ViewModel.Publisher, ViewModel.Author
                                             , ViewModel.Translator, ViewModel.Category);

            return(View(Books));
        }
Example #19
0
        public HttpResponseMessage InsertSearch(AdvancedSearchViewModel viewModel)
        {
            viewModel.CreatedOn = DateTime.Now.ToUniversalTime();
            viewModel.CreatedBy = this.UserId;
            viewModel.AccountID = this.AccountId;
            SaveAdvancedSearchResponse response = advancedSearchService.InsertSavedSearch(
                new SaveAdvancedSearchRequest()
            {
                AdvancedSearchViewModel = viewModel,
                AccountId   = this.AccountId,
                RequestedBy = this.UserId,
                RoleId      = this.RoleId
            });

            return(Request.BuildResponse(response));
        }
        public ActionResult AdvancedSearch()
        {
            var advancedSearchViewModel = new AdvancedSearchViewModel();

            advancedSearchViewModel.FacilitySiteList = new SelectList(DbContext.FacilitySites
                                                                      .Where(facilitySite => facilitySite.IsActive && !facilitySite.IsDeleted)
                                                                      .Select(x => new { x.FacilitySiteID, x.FacilityName }),
                                                                      "FacilitySiteID",
                                                                      "FacilityName");

            advancedSearchViewModel.BuildingList = new SelectList(DbContext.Assets
                                                                  .GroupBy(x => x.Building)
                                                                  .Where(x => x.Key != null && !x.Key.Equals(string.Empty))
                                                                  .Select(x => new { Building = x.Key }),
                                                                  "Building",
                                                                  "Building");

            advancedSearchViewModel.ManufacturerList = new SelectList(DbContext.Assets
                                                                      .GroupBy(x => x.Manufacturer)
                                                                      .Where(x => x.Key != null && !x.Key.Equals(string.Empty))
                                                                      .Select(x => new { Manufacturer = x.Key }),
                                                                      "Manufacturer",
                                                                      "Manufacturer");

            advancedSearchViewModel.StatusList = new SelectList(new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "Issued", Value = bool.TrueString
                },
                new SelectListItem {
                    Text = "Not Issued", Value = bool.FalseString
                }
            },
                                                                "Value",
                                                                "Text"
                                                                );

            return(View("_AdvancedSearchPartial", advancedSearchViewModel));
        }
        public async Task <ActionResult> ContactsResultViewRead([DataSourceRequest] DataSourceRequest request, string aviewModel)
        {
            AdvancedSearchViewModel viewModel = JsonConvert.DeserializeObject <AdvancedSearchViewModel>(aviewModel);

            if (viewModel.AccountID == 0)
            {
                viewModel.AccountID = this.Identity.ToAccountID();
            }
            var pageSize = request.PageSize;

            Session["AdvancedSearchVM"] = viewModel;
            AdvancedSearchResponse <ContactAdvancedSearchEntry> response;

            try
            {
                response = await advancedSearchService.RunSearchAsync(new AdvancedSearchRequest <ContactAdvancedSearchEntry>()
                {
                    SearchViewModel  = viewModel,
                    AccountId        = this.Identity.ToAccountID(),
                    RoleId           = this.Identity.ToRoleID(),
                    RequestedBy      = this.Identity.ToUserID(),
                    IsAdvancedSearch = true,
                    Limit            = pageSize,
                    PageNumber       = request.Page
                });
            }
            catch (Exception ex)
            {
                return(Json(new DataSourceResult
                {
                    Errors = ex.Message
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new DataSourceResult
            {
                Data = (dynamic)response.SearchResult.Results,
                Total = (int)response.SearchResult.TotalHits
            }, JsonRequestBehavior.AllowGet));
        }
Example #22
0
        public IActionResult AdvancedSearch(string?name, List <string> ingridients, List <string> tags, int?rating, int?timeMin, int?timeMax, string?authorName, int?difficultLevel, int?page)
        {
            var pageNumber = page ?? 1;
            int pageSize   = 9;

            ViewData["Name"]           = name;
            ViewData["Ingridients"]    = ingridients;
            ViewData["Tags"]           = tags;
            ViewData["MinTime"]        = timeMin;
            ViewData["MaxTime"]        = timeMax;
            ViewData["Rating"]         = rating;
            ViewData["AuthorName"]     = authorName;
            ViewData["DifficultLevel"] = difficultLevel;

            AdvancedSearchViewModel model = new AdvancedSearchViewModel()
            {
                Name           = name,
                Ingridients    = ingridients,
                Tags           = tags,
                TimeMin        = timeMin,
                TimeMax        = timeMax,
                Rating         = rating,
                AuthorName     = authorName,
                DifficultLevel = difficultLevel
            };

            if (ModelState.IsValid)
            {
                model.ResultRecipes = _recipeRepository.GetAdvancedSearchRecipes(model).ToList().ToPagedList(pageNumber, pageSize)
                                      .Select(e =>
                {
                    e.EncryptedId = _protector.Protect(e.Id.ToString());
                    return(e);
                });
            }

            return(View(model));
        }
Example #23
0
        public async Task <HttpResponseMessage> ExportToCSVFile(AdvancedSearchViewModel viewModel)
        {
            if (viewModel.AccountID == 0)
            {
                viewModel.AccountID = this.AccountId;
            }
            ExportSearchResponse response = await advancedSearchService.ExportSearchToCSVAsync(
                new ExportSearchRequest()
            {
                SearchViewModel = viewModel
            });

            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
            Stream stream = new MemoryStream(response.byteArray);

            result.Content = new StreamContent(stream);
            result.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = response.FileName
            };

            return(result);
        }
Example #24
0
        public ActionResult AdvancedSearch(string searchString)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            if (string.IsNullOrEmpty(searchString))
            {
                return(View());
            }

            AdvancedSearchViewModel model = new AdvancedSearchViewModel();

            ViewBag.SearchString = searchString;

            switch (Request.Form["keyword"].ToString())
            {
            case "users":
                model.Users = helper.Search(searchString);
                break;

            case "descriptions":
                model.Videos = helper.SearchDescription(searchString).ToList();
                break;

            case "comments":
                model.Comments = helper.SearchComments(searchString).ToList();
                break;

            default:
                break;
            }

            return(View(model));
        }
Example #25
0
 /// <summary>
 /// Provides a deterministic way to delete the AdvancedSearchVM static property
 /// </summary>
 public static void ClearAdvancedSearchVM()
 {
     advancedSearchVM.Cleanup();
         advancedSearchVM = null;
 }
Example #26
0
 public ActionResult AdvancedSearch_Post(AdvancedSearchViewModel model)
 {
     return(RedirectToAction("AdvancedSearch", model));
 }
Example #27
0
 /// <summary>
 /// Provides a deterministic way to delete the AdvancedSearchVM static property
 /// </summary>
 public static void ClearAdvancedSearchVM()
 {
     advancedSearchVM.Cleanup();
     advancedSearchVM = null;
 }
Example #28
0
 /// <summary>
 /// Provides a  way to create the AdvancedSearchVM property
 /// </summary>
 public static void CreateAdvancedSearchVM()
 {
     if (advancedSearchVM == null)
         {
             advancedSearchVM = new AdvancedSearchViewModel();
         }
 }
Example #29
0
        public async Task <IActionResult> AdvancedSearch()
        {
            var searchVm = new AdvancedSearchViewModel();

            return(View(searchVm));
        }
Example #30
0
        public DataTablesResponse SearchApi(IDataTablesRequest requestModel, AdvancedSearchViewModel searchViewModel)
        {
            DataTablesResponse response = null;

            if (searchViewModel.DateExtractedFrom.HasValue || searchViewModel.EmployerName != null || searchViewModel.EmployerCode != null || searchViewModel.DateSentFrom.HasValue)
            {
                //string dateExtracted = (searchViewModel.DateExtractedTo.Value - searchViewModel.DateExtractedFrom.Value).TotalDays.ToString();
                //var extracted = Convert.ToDateTime(dateExtracted);

                //var dateSent = (searchViewModel.DateSentTo.Value - searchViewModel.DateSentFrom.Value).TotalDays.ToString();
                //var sent = Convert.ToDateTime(dateSent);

                IQueryable <Message> searchQuery = uow.Messages.GetAll().Where(m => m.EmployerCode == searchViewModel.EmployerCode && m.EmployerName == searchViewModel.EmployerName).AsQueryable();
                var searchTotalCount             = searchQuery.Count();

                var searchFilteredCount = searchQuery.Count();

                // Sorting
                var searchOrderColums = requestModel.Columns.Where(x => x.Sort != null);

                //paging
                var searchData = searchQuery.OrderBy(searchOrderColums).Skip(requestModel.Start).Take(requestModel.Length);

                var searchTransformedData = from tr in searchData
                                            select new
                {
                    Id            = tr.Id,
                    MessageCode   = tr.MessageCode,
                    MobilePhone   = tr.MobilePhone,
                    Email         = tr.Email,
                    PIN           = tr.RSAPIN,
                    Fullname      = tr.FullName,
                    Status        = tr.Status,
                    IsSent        = tr.IsSent,
                    DateExtracted = tr.DateExtracted,
                    DateSent      = tr.DateSent,
                    EmployerName  = tr.EmployerName
                };

                response = DataTablesResponse.Create(requestModel, searchTotalCount, searchFilteredCount, searchTransformedData);
            }
            else
            {
                IQueryable <Message> query = uow.Messages.GetAll().AsQueryable();

                var totalCount = query.Count();

                // Apply filters
                if (!string.IsNullOrEmpty(requestModel.Search.Value))
                {
                    var value = requestModel.Search.Value.Trim();
                    query = query.Where(p =>
                                        p.FullName.ToLower().Contains(value.ToLower()) ||
                                        p.RSAPIN.ToLower().Contains(value.ToLower()) ||
                                        p.MobilePhone.ToLower().Contains(value.ToLower()) ||
                                        p.MessageCode.ToLower().Contains(value.ToLower())
                                        //p.Email.ToLower().Contains(value.ToLower())
                                        );
                }

                var filteredCount = query.Count();

                // Sorting
                var orderColums = requestModel.Columns.Where(x => x.Sort != null);

                //paging
                var data = query.OrderBy(orderColums).Skip(requestModel.Start).Take(requestModel.Length);

                var transformedData = from tr in data
                                      select new
                {
                    Id            = tr.Id,
                    MessageCode   = tr.MessageCode,
                    MobilePhone   = tr.MobilePhone,
                    Email         = tr.Email,
                    PIN           = tr.RSAPIN,
                    Fullname      = tr.FullName,
                    Status        = tr.Status,
                    IsSent        = tr.IsSent,
                    DateExtracted = tr.DateExtracted,
                    EmployerName  = tr.EmployerName
                };

                response = DataTablesResponse.Create(requestModel, totalCount, filteredCount, transformedData);
            }

            return(response);
        }