Exemplo n.º 1
0
        private void btnIdentity3_Click(object sender, EventArgs e)
        {
            var cmd = new SearchTool("调查单元图斑", this);

            cmd.OnCreate(axMapControl1.Object);
            axMapControl1.CurrentTool = cmd as ITool;
        }
Exemplo n.º 2
0
        public SearchResult Get([FromUri] SearchRequest dtoSearchRequest)
        {
            if (dtoSearchRequest == null)
            {
                HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest);
                throw new HttpResponseException(httpResponseMessage);
            }
            var searchRequest = new SearchTool.SearchRequest();

            if (dtoSearchRequest.Brands != null)
            {
                searchRequest.Brands = dtoSearchRequest.Brands.Split(',').Select(s => s.Trim()).ToArray();
            }

            if (dtoSearchRequest.Keywords != null)
            {
                searchRequest.Keywords = dtoSearchRequest.Keywords.Split(',').Select(s => s.Trim()).ToArray();
            }

            if (dtoSearchRequest.Category != null)
            {
                searchRequest.Category = _context.Categories.SingleOrDefault(c => c.LinkName == dtoSearchRequest.Category);
            }

            searchRequest.Sort           = dtoSearchRequest.Sort != null ? dtoSearchRequest.Sort : "a-z";
            searchRequest.Page           = dtoSearchRequest.Page;
            searchRequest.FilterPriceMin = dtoSearchRequest.FilterPriceMin;
            searchRequest.FilterPriceMax = dtoSearchRequest.FilterPriceMax;
            searchRequest.ItemPerPage    = ItemPerPage;

            var searchTool   = new SearchTool(_context);
            var searchResult = searchTool.Execute(searchRequest);

            var dtoSearchResult = new Dto.SearchResult();

            dtoSearchResult.Items  = searchResult.Items;
            dtoSearchResult.Brands = searchResult.Brands.Select(b => new SearchBrand()
            {
                Brand = b, Selected = searchRequest.Brands != null ? searchRequest.Brands.Contains(b.LinkName) : false
            });
            dtoSearchResult.Categories            = searchResult.Categories;
            dtoSearchResult.Page                  = searchRequest.Page;
            dtoSearchResult.PageCount             = searchResult.PageCount;
            dtoSearchResult.ItemsCount            = searchResult.ItemsCount;
            dtoSearchResult.ItemsCountAfterFilter = searchResult.ItemsCountAfterFilter;
            dtoSearchResult.ItemsPerPage          = ItemPerPage;
            dtoSearchResult.PriceMin              = searchResult.PriceMin;
            dtoSearchResult.PriceMax              = searchResult.PriceMax;

            return(dtoSearchResult);
        }
Exemplo n.º 3
0
        public ProteinSpectrumMatch(string sequence, int scanNum, double mass, int charge, string protName, string protDesc, int firstResidue, int lastResidue, double score, SearchTool searchTool = SearchTool.Unknown)
        {
            Sequence = sequence;
            ScanNum  = scanNum;
            Mass     = mass;
            Charge   = charge;

            ProteinName = protName;

            FirstResidue   = firstResidue;
            LastResidue    = lastResidue;
            SearchToolType = searchTool;
            Score          = score;
            ProteinDesc    = protDesc;
        }
Exemplo n.º 4
0
        public void ReadfileTest()
        {
            int           maxSize        = 6;
            string        inputFilePath  = @"C:\Temp\dictionary.txt";
            string        outputFilePath = @"C:\Temp\output.txt";
            List <string> wordList       = new List <string>();

            Mock <IFileHandler> handler = new Mock <IFileHandler>();

            handler.Setup(x => x.ReadFile(inputFilePath, maxSize)).Returns(new List <string>()
            {
                "test", "12", "saskatoon"
            });

            ISearchTool searchTool = new SearchTool(inputFilePath, outputFilePath, maxSize, handler.Object);

            wordList = searchTool.ReadFile();

            Assert.IsTrue(wordList.Count == 3);
        }
Exemplo n.º 5
0
        public void BuildRepositoryTest()
        {
            int           maxSize        = 6;
            string        inputFilePath  = @"C:\Temp\dictionary.txt";
            string        outputFilePath = @"C:\Temp\output.txt";
            List <string> wordList       = new List <string>();

            Mock <IFileHandler> handler = new Mock <IFileHandler>();

            handler.Setup(x => x.ReadFile(inputFilePath, maxSize)).Returns(new List <string>()
            {
                "test12", "word", "12", "reg", "ina"
            });

            ISearchTool searchTool = new SearchTool(inputFilePath, outputFilePath, maxSize, handler.Object);

            wordList = searchTool.ReadFile();

            List <string> matchList = searchTool.BuildWordRepository(wordList);

            Assert.IsTrue(matchList.Count == 3);
        }
Exemplo n.º 6
0
        public ActionResult MyRentals(MyRentalsSearchModel model)
        {
            var user  = User.Identity.Name;
            var login = AccountService.GetLoginByEmail(user);

            if (TenantService.IsLoginATenant(login))
            {
                if (String.IsNullOrWhiteSpace(model.SortOrder))
                {
                    model.SortOrder = "Latest Date";
                }

                var data = TenantService.GetMyRentals(login.Id).AsQueryable();

                switch (model.SortOrder)
                {
                case "Latest First":
                    data = data.OrderBy(s => s.CreatedOn);
                    break;

                case "Earliest First":
                    data = data.OrderByDescending(s => s.CreatedOn);
                    break;

                case "Due Date Nearest":
                    data = data.OrderBy(s => s.NextPaymenDate);
                    break;

                case "Due Date Farthest":
                    data = data.OrderByDescending(s => s.NextPaymenDate);
                    break;

                default:
                    data = data.OrderByDescending(s => s.CreatedOn);
                    break;
                }

                var allItems = data.ToPagedList(model.Page, 10);

                if (!String.IsNullOrWhiteSpace(model.SearchString))
                {
                    SearchTool searchTool   = new SearchTool();
                    int        searchType   = searchTool.CheckDisplayType(model.SearchString);
                    string     formatString = searchTool.ConvertString(model.SearchString);
                    switch (searchType)
                    {
                    case 1:
                        data = data.Where(x =>
                                          (x.AddressString != null && x.AddressString.ToLower().EndsWith(formatString)) ||
                                          (x.Model.Landlordname != null && x.Model.Landlordname.ToLower().EndsWith(formatString)) ||
                                          (x.Model.LandlordPhone != null && x.Model.LandlordPhone.ToLower().EndsWith(formatString)));
                        break;

                    case 2:
                        data = data.Where(x =>
                                          (x.AddressString != null && x.AddressString.ToLower().StartsWith(formatString)) ||
                                          (x.Model.Landlordname != null && x.Model.Landlordname.ToLower().StartsWith(formatString)) ||
                                          (x.Model.LandlordPhone != null && x.Model.LandlordPhone.ToLower().StartsWith(formatString)));
                        break;

                    case 3:
                        data = data.Where(x =>
                                          (x.AddressString != null && x.AddressString.ToLower().Contains(formatString)) ||
                                          (x.Model.Landlordname != null && x.Model.Landlordname.ToLower().Contains(formatString)) ||
                                          (x.Model.LandlordPhone != null && x.Model.LandlordPhone.ToLower().Contains(formatString)));
                        break;
                    }
                }

                var items = data.ToPagedList(model.Page, 10);
                var count = items.Count;
                items.ForEach(x => x.Model.MediaFiles.ForEach(y => y.InjectMediaModelViewProperties()));

                var result = new SearchResult {
                    SearchCount = items.Count, Items = count == 0 ? allItems : items, NoResultFound = (count == 0)
                };
                model.PagedInput = new PagedInput
                {
                    ActionName      = "MyRentals",
                    ControllerName  = "Home",
                    PagedLinkValues = new RouteValueDictionary(new { SortOrder = model.SortOrder, SearchString = model.SearchString })
                };

                var rvr        = new RouteValueDictionary(new { SearchString = model.SearchString });
                var sortOrders = new List <SortOrderModel>();
                sortOrders.Add(new SortOrderModel {
                    SortOrder = "Latest First", ActionName = "MyRentals", RouteValues = rvr.AddRouteValue("SortOrder", "Latest First")
                });
                sortOrders.Add(new SortOrderModel {
                    SortOrder = "Earliest First", ActionName = "MyRentals", RouteValues = rvr.AddRouteValue("SortOrder", "Earliest First")
                });
                sortOrders.Add(new SortOrderModel {
                    SortOrder = "Due Date Nearest", ActionName = "MyRentals", RouteValues = rvr.AddRouteValue("SortOrder", "Due Date Nearest")
                });
                sortOrders.Add(new SortOrderModel {
                    SortOrder = "Due Date Farthest", ActionName = "MyRentals", RouteValues = rvr.AddRouteValue("SortOrder", "Due Date Farthest")
                });
                model.SortOrders = sortOrders;

                model.SearchCount   = result.SearchCount;
                model.NoResultFound = result.NoResultFound;
                if (String.IsNullOrWhiteSpace(model.SearchString))
                {
                    model.Page = 1;
                }
                model.PageCount = result.Items.PageCount;
                model.Items     = result.Items;

                ViewBag.RequestTypes    = RentalService.GetRequestTypes().Where(x => x.Id != 3).ToList();
                TempData["CurrentLink"] = "MyRentals";
                return(View(model));
            }
            return(View("Error"));
        }
Exemplo n.º 7
0
        public ActionResult Inspections(POInspectionsSearchModel model)
        {
            var user  = User.Identity.Name;
            var login = AccountService.GetLoginByEmail(user);

            model.EditUrl   = "/PropertyOwners/Manage/EvaluateInspection";
            model.DeleteUrl = "/PropertyOwners/Manage/DeleteInspection";
            if (String.IsNullOrWhiteSpace(model.SortOrder))
            {
                model.SortOrder = "Latest Date";
            }
            var props   = db.OwnerProperty.Where(x => x.OwnerId == login.Id && x.Property.IsActive);
            var propsId = props.Select(x => x.Property.Id);
            var data    = db.Inspection.Where(x => propsId.Contains(x.PropertyId) && x.IsActive == true).Select(x => new
            {
                Model = new InspectionModel
                {
                    Id          = x.Id,
                    PropertyId  = x.PropertyId,
                    StatusId    = x.StatusId,
                    Message     = x.Message,
                    Reason      = x.Reason,
                    PercentDone = x.PercentDone,
                    RequestId   = x.RequestId,
                    IsViewed    = x.IsViewed ?? false,
                    IsUpdated   = x.IsUpdated,
                    MediaFiles  = x.InspectionMedia.Select(y => new MediaModel
                    {
                        Id          = y.Id,
                        NewFileName = y.NewFileName,
                        OldFileName = y.OldFileName,
                    }).ToList(),
                    LandlordMedia = x.PropertyRequest.PropertyRequestMedia.Select(k => new MediaModel1
                    {
                        Id          = k.Id,
                        NewFileName = k.NewFileName,
                        OldFileName = k.OldFileName,
                        Status      = "load",
                    }).ToList()
                },
                Address = new AddressViewModel
                {
                    AddressId = x.Property.Address.AddressId,
                    Number    = x.Property.Address.Number.Replace(" ", ""),
                    Street    = x.Property.Address.Street.Trim(),
                    City      = x.Property.Address.City.Trim(),
                    Suburb    = x.Property.Address.Suburb.Trim() ?? "",
                    PostCode  = x.Property.Address.PostCode.Replace(" ", "")
                },
                PropertyAddress = x.Property.Address.Number.Replace(" ", "") + " " + x.Property.Address.Street.Trim() + " " + x.Property.Address.City.Trim() + " " + x.Property.Address.Suburb.Trim() + " " + x.Property.Address.PostCode.Replace(" ", ""),
                Status          = x.InspectionStatus.Name,
                CreatedOn       = x.CreatedOn,
                DueDate         = x.PropertyRequest.DueDate,
            });
            var allItems = data.OrderByDescending(x => x.CreatedOn).ToPagedList(model.Page, 10);

            switch (model.SortOrder)
            {
            case "Highest Progress":
                data = data.OrderByDescending(s => s.Model.PercentDone);
                break;

            case "Lowest Progress":
                data = data.OrderBy(s => s.Model.PercentDone);
                break;

            case "Earliest Date":
                data = data.OrderBy(s => s.CreatedOn);
                break;

            case "Latest Date":
                data = data.OrderByDescending(s => s.CreatedOn);
                break;

            default:
                data = data.OrderByDescending(s => s.CreatedOn);
                break;
            }
            if (!String.IsNullOrWhiteSpace(model.SearchString))
            {
                SearchTool searchTool   = new SearchTool();
                int        searchType   = searchTool.CheckDisplayType(model.SearchString);
                string     formatString = searchTool.ConvertString(model.SearchString);
                switch (searchType)
                {
                case 1:
                    data = data.Where(x => x.Model.Message.ToLower().EndsWith(formatString) ||
                                      x.PropertyAddress.ToLower().EndsWith(formatString));
                    break;

                case 2:
                    data = data.Where(x => x.Model.Message.ToLower().StartsWith(formatString) ||
                                      x.PropertyAddress.ToLower().StartsWith(formatString));
                    break;

                case 3:
                    data = data.Where(x => x.Model.Message.ToLower().Contains(formatString) ||
                                      x.PropertyAddress.ToLower().Contains(formatString));
                    break;
                }
            }
            var items = data.ToPagedList(model.Page, 10);
            var count = items.Count;

            items = count == 0 ? allItems : items;
            items.ToList().ForEach(x => x.Model.MediaFiles.ForEach(y => y.InjectMediaModelViewProperties()));
            items.ToList().ForEach(x => x.Model.LandlordMedia.ForEach(y => y.InjectMediaModelViewProperties1()));

            var result = new SearchResult {
                SearchCount = items.Count, Items = count == 0 ? allItems : items
            };

            model.PagedInput = new PagedInput
            {
                ActionName      = "Inspections",
                ControllerName  = "Manage",
                PagedLinkValues = new RouteValueDictionary(new { SortOrder = model.SortOrder, SearchString = model.SearchString })
            };
            var rvr        = new RouteValueDictionary(new { SearchString = model.SearchString });
            var sortOrders = new List <SortOrderModel>();

            sortOrders.Add(new SortOrderModel {
                SortOrder = "Highest Progress", ActionName = "Inspections", RouteValues = rvr.AddRouteValue("SortOrder", "Highest Progress")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Lowest Progress", ActionName = "Inspections", RouteValues = rvr.AddRouteValue("SortOrder", "Lowest Progress")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Latest Date", ActionName = "Inspections", RouteValues = rvr.AddRouteValue("SortOrder", "Latest Date")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Earliest Date", ActionName = "Inspections", RouteValues = rvr.AddRouteValue("SortOrder", "Earliest Date")
            });
            model.SortOrders  = sortOrders;
            model.SearchCount = result.SearchCount;
            if (String.IsNullOrWhiteSpace(model.SearchString))
            {
                model.Page = 1;
            }
            model.PageCount = result.Items.PageCount;
            model.Items     = result.Items;

            return(View(model));
        }
Exemplo n.º 8
0
        public ActionResult Index(POPropSearchModel model)
        {
            var user  = User.Identity.Name;
            var login = AccountService.GetLoginByEmail(user);

            if (String.IsNullOrWhiteSpace(model.SortOrder))
            {
                model.SortOrder = "Latest Date";
            }
            var prop = db.OwnerProperty.Where(x => x.PropertyId == 2678).First();
            var data = db.OwnerProperty.Where(x => x.Person.Login.UserName == User.Identity.Name && x.Property.IsActive)
                       .Select(x => new PropViewModel {
                Model = new PropertyModel {
                    Id               = x.PropertyId,
                    PropertyTypeId   = x.Property.PropertyTypeId,
                    Name             = x.Property.Name,
                    Description      = x.Property.Description,
                    Bedroom          = x.Property.Bedroom,
                    Bathroom         = x.Property.Bathroom,
                    LandSqm          = x.Property.LandSqm,
                    ParkingSpace     = x.Property.ParkingSpace,
                    FloorArea        = x.Property.FloorArea,
                    TargetRent       = x.Property.TargetRent,
                    TargetRentTypeId = x.Property.TargetRentTypeId,
                    YearBuilt        = x.Property.YearBuilt,
                    IsOwnerOccupied  = x.Property.IsOwnerOccupied,
                    Address          = new AddressViewModel
                    {
                        AddressId = x.Property.Address.AddressId,
                        CountryId = x.Property.Address.CountryId,
                        Number    = x.Property.Address.Number.Replace(" ", ""),
                        Street    = x.Property.Address.Street.Trim(),
                        City      = x.Property.Address.City.Trim(),
                        Suburb    = x.Property.Address.Suburb.Trim() ?? "",
                        PostCode  = x.Property.Address.PostCode.Replace(" ", ""),
                        Latitude  = x.Property.Address.Lat,
                        Longitude = x.Property.Address.Lng,
                    },
                    MediaFiles = x.Property.PropertyMedia.Select(y => new MediaModel {
                        Id = y.Id, NewFileName = y.NewFileName, OldFileName = y.OldFileName
                    }).ToList()
                },
                PropertyTypeName = x.Property.PropertyType.Name,
                CreatedOn        = x.Property.CreatedOn,
                PurchasePrice    = x.Property.PropertyFinance.PurchasePrice,
                CurrentHomeValue = x.Property.PropertyFinance.CurrentHomeValue,
                TenantCount      = x.Property.TenantProperty.Where(y => y.IsActive ?? true).Count(),
            });
            var allItems = data.OrderByDescending(x => x.CreatedOn).ToPagedList(model.Page, 10);

            switch (model.SortOrder)
            {
            case "Name":
                data = data.OrderBy(s => s.Model.Name);
                break;

            case "Name(Desc)":
                data = data.OrderByDescending(s => s.Model.Name);
                break;

            case "Latest Date":
                data = data.OrderByDescending(s => s.CreatedOn);
                break;

            case "Earliest Date":
                data = data.OrderBy(s => s.CreatedOn);
                break;

            default:
                data = data.OrderByDescending(s => s.CreatedOn);
                break;
            }
            if (!String.IsNullOrWhiteSpace(model.SearchString))
            {
                SearchTool searchTool   = new SearchTool();
                int        searchType   = searchTool.CheckDisplayType(model.SearchString);
                string     formatString = searchTool.ConvertString(model.SearchString);
                switch (searchType)
                {
                case 1:
                    data = data.Where(x => x.Model.Name.ToLower().EndsWith(formatString) ||
                                      x.Model.Address.City.ToLower().EndsWith(formatString) ||
                                      x.Model.Address.Suburb.ToLower().EndsWith(formatString));
                    break;

                case 2:
                    data = data.Where(x => x.Model.Name.ToLower().StartsWith(formatString) ||
                                      x.Model.Address.City.ToLower().StartsWith(formatString) ||
                                      x.Model.Address.Suburb.ToLower().StartsWith(formatString));
                    break;

                case 3:
                    data = data.Where(x => x.Model.Name.ToLower().Contains(formatString) ||
                                      x.Model.Address.City.ToLower().Contains(formatString) ||
                                      x.Model.Address.Suburb.ToLower().Contains(formatString));
                    break;
                }
            }
            var items = data.ToPagedList(model.Page, 10);
            var count = items.Count;

            items = count == 0 ? allItems : items;
            items.ToList().ForEach(x => x.Model.MediaFiles.ForEach(y => y.InjectMediaModelViewProperties()));
            var result = new SearchResult {
                SearchCount = items.Count, Items = count == 0 ? allItems : items
            };

            model.PagedInput = new PagedInput
            {
                ActionName      = "Index",
                ControllerName  = "Home",
                PagedLinkValues = new RouteValueDictionary(new { SortOrder = model.SortOrder, SearchString = model.SearchString })
            };
            var rvr        = new RouteValueDictionary(new { SearchString = model.SearchString });
            var sortOrders = new List <SortOrderModel>();

            sortOrders.Add(new SortOrderModel {
                SortOrder = "Name", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Name")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Name(Desc)", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Name(Desc)")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Latest Date", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Latest Date")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Earliest Date", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Earliest Date")
            });
            model.SortOrders  = sortOrders;
            model.SearchCount = result.SearchCount;
            if (String.IsNullOrWhiteSpace(model.SearchString))
            {
                model.Page = 1;
            }
            model.PageCount       = result.Items.PageCount;
            model.Items           = result.Items;
            model.EditUrl         = "/PropertyOwners/Home/Edit";
            model.DeleteUrl       = "/PropertyOwners/Home/Delete";
            model.CanListRental   = allItems.Any();
            ViewBag.Frequencies   = PropertyOwnerService.GetAllPaymentFrequencies();
            ViewBag.PropertyTypes = PropertyService.GetAllProprtyTypes();
            return(View(model));
        }
Exemplo n.º 9
0
        // GET: Users/Home
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            // var userContext = db.Person;
            var loginContext   = db.Login;
            var personContext  = db.Person;
            var listofRoles    = db.Role;
            var listofRoleList = db.LoginRole;

            ViewBag.SearchCount        = 1;
            ViewBag.CurrentSort        = sortOrder;
            ViewBag.CurrentFilter      = searchString;
            ViewBag.FirstNameSortParm  = sortOrder == "Fname_asc" ? "Fname" : "Fname_asc";
            ViewBag.MiddleNameSortParm = sortOrder == "Mname_asc" ? "Mname" : "Mname_asc";
            ViewBag.LastNameSortParm   = sortOrder == "Lname_asc" ? "Lname" : "Lname_asc";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            //ViewBag.CurrentFilter = searchString;
            //ViewBag.CurrentFilter2 = searchString;

            // login table join with person table
            var userContextFull = from login in loginContext
                                  join p in personContext
                                  on login.Id equals p.Id
                                  where p.IsActive == true
                                  select new
            {
                Id = p.Id,
                //  Loginrole = login.LoginRole,
                UserName     = login.UserName,
                LoginId      = p.LoginId,
                FirstName    = p.FirstName,
                MiddleName   = p.MiddleName ?? "",
                LastName     = p.LastName,
                Language     = p.Language,
                PlaceOfBirth = p.PlaceOfBirth,
                Occupation   = p.Occupation,
                LinkedinUrl  = p.LinkedinUrl,
                IsActive     = p.IsActive,
                CreatedOn    = p.CreatedOn.ToString(),
                ProfilePhoto = p.ProfilePhoto,
                //ProfilePhoto = new MediaModel
                //{
                //    OldFileName = p.ProfilePhoto

                //},
                Address1 = new AddressViewModel
                {
                    AddressId = p.PhysicalAddressId,
                    CountryId = p.Address1.CountryId,
                    Number    = p.Address1.Number,
                    Street    = p.Address1.Street,
                    City      = p.Address1.City,
                    Suburb    = p.Address1.Suburb,
                    PostCode  = p.Address1.PostCode,
                },
                Address = new AddressViewModel
                {
                    AddressId = p.BillingAddressId,
                    CountryId = p.Address.CountryId,
                    Number    = p.Address.Number,
                    Street    = p.Address.Street,
                    City      = p.Address.City,
                    Suburb    = p.Address.Suburb,
                    PostCode  = p.Address.PostCode,
                }
            };

            var userContext = userContextFull;

            switch (sortOrder)
            {
            case "Fname":
                userContext = userContext.OrderByDescending(s => s.FirstName);
                break;

            case "Fname_asc":
                userContext = userContext.OrderBy(s => s.FirstName);
                break;

            case "Mname":
                userContext = userContext.OrderByDescending(s => s.MiddleName);
                break;

            case "Mname_asc":
                userContext = userContext.OrderBy(s => s.MiddleName);
                break;

            case "Lname":
                userContext = userContext.OrderByDescending(s => s.LastName);
                break;

            case "Lname_asc":
                userContext = userContext.OrderBy(s => s.LastName);
                break;

            default:
                userContext = userContext.OrderBy(s => s.FirstName);
                sortOrder   = "Fname_asc";
                break;
            }

            if (!String.IsNullOrWhiteSpace(searchString))
            {
                SearchTool searchTool   = new SearchTool();
                int        searchType   = searchTool.CheckDisplayType(searchString);
                string     formatString = searchTool.ConvertString(searchString);
                switch (searchType)
                {
                case 1:
                    userContext = userContext.Where(userlist => userlist.FirstName.EndsWith(formatString) ||
                                                    userlist.MiddleName.EndsWith(formatString) ||
                                                    userlist.LastName.EndsWith(formatString) ||
                                                    userlist.Language.EndsWith(formatString) ||
                                                    userlist.Address.City.EndsWith(formatString) ||
                                                    userlist.Address.Suburb.EndsWith(formatString) ||
                                                    userlist.Address1.City.EndsWith(formatString) ||
                                                    userlist.Address1.Suburb.EndsWith(formatString)
                                                    );
                    break;

                case 2:
                    userContext = userContext.Where(userlist => userlist.FirstName.StartsWith(formatString) ||
                                                    userlist.MiddleName.StartsWith(formatString) ||
                                                    userlist.LastName.StartsWith(formatString) ||
                                                    userlist.Language.StartsWith(formatString) ||
                                                    userlist.Address.City.StartsWith(formatString) ||
                                                    userlist.Address.Suburb.StartsWith(formatString) ||
                                                    userlist.Address1.City.StartsWith(formatString) ||
                                                    userlist.Address1.Suburb.StartsWith(formatString)
                                                    );
                    break;

                case 3:
                    userContext = userContext.Where(userlist => userlist.FirstName.Contains(formatString) ||
                                                    userlist.MiddleName.Contains(formatString) ||
                                                    userlist.LastName.Contains(formatString) ||
                                                    userlist.Language.Contains(formatString) ||
                                                    userlist.Address.City.Contains(formatString) ||
                                                    userlist.Address.Suburb.Contains(formatString) ||
                                                    userlist.Address1.City.Contains(formatString) ||
                                                    userlist.Address1.Suburb.Contains(formatString)
                                                    );
                    break;
                }
            }

            if (userContext.Count() == 0)
            {
                ViewBag.SearchCount   = 0;
                TempData["search"]    = searchString ?? "";
                ViewBag.CurrentFilter = "";
                //ViewBag.CurrentFilter = searchString ?? "";
                userContext = userContextFull.OrderBy(q => q.FirstName);
            }

            int pageNumber = (page ?? 1);

            var users = userContext
                        .Where(q => q.IsActive == true)
                        .Select(q => new UserViewModel
            {
                Id           = q.Id,
                LoginId      = q.LoginId,
                UserName     = q.UserName,
                FirstName    = q.FirstName,
                MiddleName   = q.MiddleName ?? "",
                LastName     = q.LastName,
                Language     = q.Language,
                PlaceOfBirth = q.PlaceOfBirth,
                Occupation   = q.Occupation,
                Linkedin     = q.LinkedinUrl,
                IsActive     = q.IsActive,
                CreatedOn    = q.CreatedOn.ToString(),
                ProfilePhoto = q.ProfilePhoto,

                PhysicalAddress = new AddressViewModel
                {
                    AddressId = q.Address1.AddressId,
                    CountryId = q.Address1.CountryId,
                    Number    = q.Address1.Number,
                    Street    = q.Address1.Street,
                    City      = q.Address1.City,
                    Suburb    = q.Address1.Suburb,
                    PostCode  = q.Address1.PostCode,
                },
                BillingAddress = new AddressViewModel
                {
                    AddressId = q.Address.AddressId,
                    CountryId = q.Address.CountryId,
                    Number    = q.Address.Number,
                    Street    = q.Address.Street,
                    City      = q.Address.City,
                    Suburb    = q.Address.Suburb,
                    PostCode  = q.Address.PostCode,
                }
            }).ToList();       //.ToPagedList(pageNumber, 10);

            users.ForEach(x =>
            {
                x.ProfilePhoto = Url.Content("~/images/" + x.ProfilePhoto);
            });



            foreach (var item in users)
            {
                //users.ForEach(x =>
                //{
                //    x.MediaFiles.ForEach(y => {
                //        y.Data = Url.Content("~/images/" + y.NewFileName);
                //        y.MediaType = MediaService.GetMediaType(y.NewFileName);
                //    });

                //  item.ProfilePhoto = new MediaModel { Data = Url.Content("~/images/" + item.ProfilePhoto) };
                //});



                var singleUserRoles = from role in listofRoles
                                      from loginrole in listofRoleList.Where(q => q.PersonId == item.LoginId && (role.Id == q.RoleId)).DefaultIfEmpty()
                                      select new
                {
                    Id              = role.Id,              //id from the role tabe
                    RoleName        = role.Name,
                    IsActive        = (bool?)loginrole.IsActive ?? false,
                    PendingApproval = (bool?)loginrole.PendingApproval ?? false,
                    LoginId         = item.LoginId
                };

                foreach (var userRole in singleUserRoles)
                {
                    item.UserRoleList.Add(new RoleViewModel()
                    {
                        Id              = userRole.Id,
                        Name            = userRole.RoleName,
                        loginId         = userRole.LoginId,
                        IsActive        = userRole.IsActive,
                        PendingApproval = userRole.PendingApproval
                    });
                }
            }



            if (Request.IsAjaxRequest())
            {
                return(PartialView("_PagedUsers", users.ToPagedList(pageNumber, 10)));
            }
            TempData["CurrentLink"] = "Admin";
            return(View(users.ToPagedList(pageNumber, 10)));
        }
Exemplo n.º 10
0
        public List <MatchPalletPlanModel> GetMathPalletPlanByIce(string mathPalletCode)
        {
            var list = new List <MatchPalletPlanModel>();

            try
            {
                var standardDataModel = PDAServiceIceProxy.GetMatchPalletPlan(mathPalletCode, PageModel.Page, 0, PageModel.Limit, "", (string.IsNullOrEmpty(mathPalletCode) ? "" : SearchTool.JsonSerialzable("MatchPalletCode," + mathPalletCode)));
                if (!standardDataModel.success)
                {
                    throw new Exception(standardDataModel.msg);
                }
                PageModel.TotalCount = standardDataModel.total;
                PageModel.PageCount  = (int)Math.Ceiling((double)PageModel.TotalCount / PageModel.Limit);
                list = standardDataModel.data;
            }
            catch (Exception e)
            {
                throw new Exception("出现异常,异常信息:" + e.Message);
            }
            return(list);
        }
Exemplo n.º 11
0
        public ActionResult GetJobQuotes(QuotesSearchViewModel model)
        {
            if (model.SortOrder == null)
            {
                model.SortOrder = "Latest Listing";
            }
            var data = db.JobQuote.Where(x => x.Status.ToLower() == "opening")
                       .Select(x => new {
                Model = new JobQuoteModel
                {
                    Id           = x.Id,
                    JobRequestId = x.JobRequestId,
                    Amount       = x.Amount,
                    Status       = x.Status,
                    Note         = x.Note,
                    IsViewed     = x.IsViewed,
                    MediaFiles   = x.JobQuoteMedia.Select(y => new MediaModel
                    {
                        Id          = y.Id,
                        OldFileName = y.FileName.Substring(36),
                        NewFileName = y.FileName,
                    }).ToList(),
                },
                CreatedOn    = x.CreatedOn,
                ProviderName = x.ServiceProvider != null ? x.ServiceProvider.Person != null ? x.ServiceProvider.Person.FirstName : "" : "",
                CompanyName  = x.ServiceProvider != null ? x.ServiceProvider.Company != null ? x.ServiceProvider.Company.Name : "" : "",
            });

            if (model.MarketJobId.HasValue)
            {
                data = data.Where(x => x.Model.JobRequestId == model.MarketJobId);
                var mJob = db.TenantJobRequest.FirstOrDefault(x => x.Id == model.MarketJobId);
                model.MarketJob = mJob.MapTo <MarketJobModel>();
            }
            var allItems = data.OrderByDescending(x => x.CreatedOn).ToPagedList(model.Page, 10);

            switch (model.SortOrder)
            {
            case "Company (A-Z)":
                data = data.OrderBy(s => s.CompanyName);
                break;

            case "Company (Z-A)":
                data = data.OrderByDescending(s => s.CompanyName);
                break;

            case "Lowest Amount":
                data = data.OrderBy(s => s.Model.Amount);
                break;

            case "Highest Amount":
                data = data.OrderByDescending(s => s.Model.Amount);
                break;

            default:
                data = data.OrderByDescending(s => s.Model.Amount);
                break;
            }
            if (!String.IsNullOrWhiteSpace(model.SearchString))
            {
                SearchTool searchTool   = new SearchTool();
                int        searchType   = searchTool.CheckDisplayType(model.SearchString);
                string     formatString = searchTool.ConvertString(model.SearchString);

                switch (searchType)
                {
                case 1:
                    data = data.Where(x => x.Model.Amount.ToString() == formatString ||
                                      x.CompanyName.ToLower().StartsWith(formatString) ||
                                      x.Model.Note.ToLower().StartsWith(formatString));
                    break;

                case 2:
                    data = data.Where(x => x.Model.Amount.ToString() == formatString ||
                                      x.CompanyName.ToLower().EndsWith(formatString) ||
                                      x.Model.Note.ToLower().EndsWith(formatString));
                    break;

                case 3:
                    double number;
                    if (Double.TryParse(formatString, out number))
                    {
                        data = data.Where(y => double.Parse(y.Model.Amount.ToString().Split(',')[0]) <= double.Parse(formatString.Split(',')[0]));
                    }
                    else
                    {
                        data = data.Where(y => y.Model.Note.ToLower().Contains(formatString));
                    }
                    break;
                }
            }
            var items = data.ToPagedList(model.Page, 10);
            var count = items.Count;

            items = count == 0 ? allItems : items;
            items.ToList().ForEach(x => x.Model.MediaFiles.ForEach(y => y.InjectMediaModelViewProperties()));
            var result = new SearchResult {
                SearchCount = items.Count, Items = count == 0 ? allItems : items
            };

            model.PagedInput = new PagedInput
            {
                ActionName      = "GetJobQuotes",
                ControllerName  = "Home",
                PagedLinkValues = new RouteValueDictionary(new { SortOrder = model.SortOrder, SearchString = model.SearchString, MarketJobId = model.MarketJobId })
            };
            var formInputs = new List <SearchInput>();

            formInputs.Add(new SearchInput {
                Name = "MarketJobId", Value = model.MarketJobId.ToString()
            });
            model.InputValues = formInputs;
            var rvr        = new RouteValueDictionary(new { SearchString = model.SearchString, MarketJobId = model.MarketJobId });
            var sortOrders = new List <SortOrderModel>();

            sortOrders.Add(new SortOrderModel {
                SortOrder = "Company (A-Z)", ActionName = "GetJobQuotes", RouteValues = rvr.AddRouteValue("SortOrder", "Name")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Company (Z-A)", ActionName = "GetJobQuotes", RouteValues = rvr.AddRouteValue("SortOrder", "Company (Z-A)")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Lowest Amount", ActionName = "GetJobQuotes", RouteValues = rvr.AddRouteValue("SortOrder", "Lowest Amount")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Highest Amount", ActionName = "GetJobQuotes", RouteValues = rvr.AddRouteValue("SortOrder", "Higest Amount")
            });
            model.SortOrders  = sortOrders;
            model.SearchCount = result.SearchCount;
            if (String.IsNullOrWhiteSpace(model.SearchString))
            {
                model.Page = 1;
            }
            model.PageCount = result.Items.PageCount;
            model.Items     = result.Items;
            var currentJob = db.TenantJobRequest.Where(x => x.Id == model.MarketJobId).FirstOrDefault();

            model.Address = currentJob.Property.Address?.ToAddressString() ?? "";
            return(View(model));
        }