public ActionResult ViewCompany()
        {
            ApplicationDbContext context      = new ApplicationDbContext();
            List <Company>       NewCompanies = new List <Company>();
            var    userid            = User.Identity.GetUserId();
            string ZoneGroup         = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            int    SingleZoneGroupId = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId;

            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            ViewBag.SelectedCompany    = TempData["SelectedCompany"] as string;
            SearchCompany temp = TempData["searchcompany"] as SearchCompany;
            SearchCompany SearchCompanyViewModels = new SearchCompany();

            NewCompanies = db.Company.Select(x => x).OrderBy(x => x.CompanyName).Take(10).ToList();
            SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);

            SearchCompanyViewModels.CompanyList = searchCompanyPerGroup.Companies;

            var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();

            foreach (var item in bill)
            {
                SearchCompanyViewModels.Category.Add(item.Category);
            }
            SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
            if (ViewBag.SelectedCompany == null)
            {
                return(View(SearchCompanyViewModels));
            }
            else
            {
                return(View("ViewCompany", temp));
            }
        }
Пример #2
0
        public ActionResult GetAllCompanies(SearchCompany searchCompany)
        {
            var company = (from s in db.WorkNC_Company
                           where ((String.IsNullOrEmpty(searchCompany.CompanyName) || s.CompanyName.Contains(searchCompany.CompanyName)) &&
                                  (searchCompany.isDeleted == true || s.isDeleted == false))
                           select s).OrderBy(s => s.CompanyName).ToList();

            return(Json(company, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        private static SearchCompany AddCompany(SearchCompany company)
        {
            SearchCompany existingItem = Companies.FirstOrDefault(x => x.Id == company.Id);

            if (existingItem != null)
            {
                return(existingItem);
            }

            Companies.Add(company);
            return(company);
        }
Пример #4
0
        public async Task TestSearchCompanyAsync()
        {
            await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchCompanyAsync("20th", i));

            SearchContainer <SearchCompany> result = await TMDbClient.SearchCompanyAsync("20th");

            SearchCompany item = result.Results.Single(s => s.Id == 25);

            await Verify(item);

            TestImagesHelpers.TestImagePaths(new[] { item.LogoPath });
        }
Пример #5
0
        public ActionResult ViewRentalsRPG()
        {
            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole     = roleAssignmentMatrix.Rentals;
            ViewBag.CompanySelected = "OK";
            SearchCompany temp = TempData["SearchCompany"] as SearchCompany;

            ViewBag.TransactionSuccess = TempData["TransactionSuccess"] as string;
            TempData.Keep("SearchCompany");
            return(View("ViewRentals", temp));
        }
Пример #6
0
        public void TestSearchCompany()
        {
            TestHelpers.SearchPages(i => Config.Client.SearchCompanyAsync("20th", i).Result);

            SearchContainer <SearchCompany> result = Config.Client.SearchCompanyAsync("20th").Result;

            Assert.True(result.Results.Any());
            SearchCompany item = result.Results.SingleOrDefault(s => s.Id == 25);

            Assert.NotNull(item);
            Assert.Equal(25, item.Id);
            Assert.True(TestImagesHelpers.TestImagePath(item.LogoPath), "item.LogoPath was not a valid image path, was: " + item.LogoPath);
            Assert.Equal("20th Century Fox", item.Name);
        }
Пример #7
0
        public void TestSearchCompany()
        {
            TestHelpers.SearchPages(i => _config.Client.SearchCompany("20th", i).Result);

            SearchContainer <SearchCompany> result = _config.Client.SearchCompany("20th").Result;

            Assert.IsTrue(result.Results.Any());
            SearchCompany item = result.Results.SingleOrDefault(s => s.Id == 25);

            Assert.IsNotNull(item);
            Assert.AreEqual(25, item.Id);
            Assert.AreEqual("/nM2MfoMqzJQRiSynsDabOtFKetD.png", item.LogoPath);
            Assert.AreEqual("20th Century Fox", item.Name);
        }
        public async Task <Company> GetCompany(SearchCompany request)
        {
            var query = _queryFactory
                        .Query(TableName)
                        .When(request.Columns.AnyItem(),
                              q => q.Select(request.Columns))
                        .When(request.Id.HasValue, q => q.Where("Id", request.Id))
                        .When(request.Name.IsNotNullOrEmpty(), q => q.WhereContains("Name", request.Name))
                        .When(request.IsActive.IsNotNull(), q => q.Where("IsActive", request.IsActive.ConvertToByte()))
                        .OrderBy("Id")
                        .FirstOrDefaultAsync <Company>();

            return(await query.ConfigureAwait(false));
        }
Пример #9
0
        public ActionResult SearchActionResult()
        {
            if (Request.Form.AllKeys.Contains("cityName"))
            {
                // Release all the acquired resources(if any) for new Http Search request
                if (SearchCompany.CountPageList != 0)
                {
                    SearchCompany.ReleaseResource();
                }

                _cityName = Request.Form["cityName"].ToString();

                // Getting list of objects for all the companies
                _company = SearchCompany.GiveCompanyDetails(_cityName);
            }
            else
            {
                if (Request.Form.AllKeys.Contains("nextButton"))
                {
                    if (SearchCompany.CountPrevClicked != 0)
                    {
                        // Getting List of objects for all the next available companies
                        _company = SearchCompany.GetNextResults();
                    }
                    else
                    {
                        // Getting list of objects for all the companies for available token
                        _company = SearchCompany.GiveCompanyDetails(_cityName, SearchCompany.NextPageToken);
                    }
                }

                if (Request.Form.AllKeys.Contains("prevButton"))
                {
                    // Getting List of objects for all the previous available companies
                    _company = SearchCompany.GetPreviousResults();
                }
            }

            ViewBag.Companies           = _company;
            ViewData["CityName"]        = _cityName;
            ViewData["isToken"]         = SearchCompany.IsToken;
            ViewData["hasPreviousPage"] = SearchCompany.HasPreviousPage;
            ViewBag.AvailableResults    = SearchCompany.CountPageList;

            return(View());
        }
Пример #10
0
        public async Task <IActionResult> SearchCompany([FromBody] SearchCompany searchCompany)
        {
            var mapped = _mapper.Map <SearchCompanyDTO>(searchCompany);

            try
            {
                var result = await _companyService.SearchCompany(mapped);

                var resultMapped = _mapper.Map <ICollection <CompanySearchResult> >(result);
                return(StatusCode(200, new { Results = resultMapped }));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(StatusCode(500));
            }
        }
Пример #11
0
 /// <summary>
 /// Convert a <see cref="SearchCompany"/> into a <see cref="Studio"/>.
 /// </summary>
 /// <param name="company">The company to convert.</param>
 /// <param name="provider">The provider representing TheMovieDb.</param>
 /// <returns>The converted company as a <see cref="Studio"/>.</returns>
 public static Studio ToStudio(this SearchCompany company, Provider provider)
 {
     return(new Studio
     {
         Slug = Utility.ToSlug(company.Name),
         Name = company.Name,
         ExternalIDs = new[]
         {
             new MetadataID
             {
                 Provider = provider,
                 Link = $"https://www.themoviedb.org/company/{company.Id}",
                 DataID = company.Id.ToString()
             }
         }
     });
 }
Пример #12
0
        public async Task Should_Return_Company_When_UserId_Is_1()
        {
            // Arrange
            var userId        = 1;
            var requestFilter = new SearchCompany()
            {
                Id = userId
            };

            var expectedResult = AllCompanies.FirstOrDefault(p => p.Id == userId);

            // Act
            var result = await _companyService
                         .GetCompany(requestFilter).ConfigureAwait(false);


            // Assert
            Assert.NotNull(expectedResult);
            Assert.Equal(expectedResult.Id, result.Id);
            Assert.Equal(expectedResult.Name, result.Name);
            Assert.Equal(expectedResult.IsActive, result.IsActive);
        }
Пример #13
0
        private void SearchCompanies(List <SearchCompany> itemList, string query)
        {
            foreach (SearchCompany item in itemList)
            {
                AddCompany(item);
            }

            SearchCompany match = Companies.FirstOrDefault(x => x.Name.Equals(query, StringComparison.OrdinalIgnoreCase));

            if (match == null)
            {
                match = Companies.FirstOrDefault(x => x.Name.StartsWith(query, StringComparison.OrdinalIgnoreCase));
            }
            if (match == null)
            {
                match = Companies.FirstOrDefault(x => x.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) > 0);
            }

            if (match != null)
            {
                SelectedItems.Add(match);
            }
        }
 public Task <Company> GetCompany(SearchCompany request)
 {
     return(_companyRepository.GetCompany(request));
 }
Пример #15
0
        public JsonResult returnCompany(string zonename, string zonegroupcode, string enttype, string comp)
        {
            SearchCompany companysearch = new SearchCompany();


            var    userid     = User.Identity.GetUserId();
            string ZoneGroupx = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;

            if (comp.Length >= 3)
            {
                if (zonegroupcode == null)
                {
                    if (enttype == "")
                    {
                        if (zonename == "All")
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == ZoneGroupx
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                        else
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == ZoneGroupx && t2.ZoneCode == zonename && t1.CompanyName.StartsWith(comp)
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                    }
                    else if (enttype == "All")
                    {
                        if (zonename == "All")
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == ZoneGroupx && t1.CompanyName.StartsWith(comp)
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                        else
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == ZoneGroupx && t2.ZoneCode == zonename && t1.CompanyName.StartsWith(comp)
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                    }
                    else
                    {
                        var selcom = from t1 in db.Company
                                     join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                     join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                         where t3.ZoneGroupCode == ZoneGroupx && t2.ZoneCode == zonename && t1.EnterpriseType == enttype && t1.CompanyName.StartsWith(comp)
                                     orderby t1.CompanyName
                                     select t1;

                        companysearch.CompanyList = selcom.ToList();
                    }
                }
                else
                {
                    if (enttype == "")
                    {
                        if (zonename == "All")
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == zonegroupcode && t1.CompanyName.StartsWith(comp)
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                        else
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == zonegroupcode && t2.ZoneCode == zonename && t1.CompanyName.StartsWith(comp)
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                    }
                    else if (enttype == "All")
                    {
                        if (zonename == "All")
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == zonegroupcode && t1.CompanyName.StartsWith(comp)
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                        else
                        {
                            var selcom = from t1 in db.Company
                                         join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                         join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                             where t3.ZoneGroupCode == zonegroupcode && t2.ZoneCode == zonename && t1.CompanyName.StartsWith(comp)
                                         orderby t1.CompanyName
                                         select t1;

                            companysearch.CompanyList = selcom.ToList();
                        }
                    }
                    else
                    {
                        var selcom = from t1 in db.Company
                                     join t2 in db.Zone on t1.ZoneCode equals t2.ZoneCode
                                     join t3 in db.ZoneGroup on t2.ZoneGroup equals t3.ZoneGroupId.ToString()
                                         where t3.ZoneGroupCode == zonegroupcode && t2.ZoneCode == zonename && t1.EnterpriseType == enttype && t1.CompanyName.StartsWith(comp)
                                     orderby t1.CompanyName
                                     select t1;

                        companysearch.CompanyList = selcom.ToList();
                    }
                }
            }
            return(Json(companysearch));



            //if (a != "All")
            //{
            //    companysearch.CompanyList = db.Company.OrderBy(x=> x.CompanyName).Where(x => x.ZoneCode == a).ToList();
            //}
            //else
            //{
            //    companysearch.CompanyList = db.Company.SqlQuery("Select * from Companies ORDER BY CompanyName ASC").ToList();
            //}
        }
        public ActionResult UpdateCompany(FormCollection frmcollection)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var     userid             = User.Identity.GetUserId();
            string  ZoneGroup          = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            int     SingleZoneGroupId  = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId;
            Company compinfo           = null;
            int     ParsedIntCompanyID = int.Parse(frmcollection["CompanyID"]);

            compinfo = db.Company.Find(ParsedIntCompanyID);
            SearchCompany  searchcompany1 = new SearchCompany();
            List <Company> NewCompanies   = new List <Company>();

            if (compinfo != null)
            {
                //compinfo.CompanyCode = frmcollection["CompanyCode"].ToString();
                compinfo.CompanyName           = frmcollection["CompanyName"].ToString();
                compinfo.Phase                 = frmcollection["Phase"].ToString();
                compinfo.Address               = frmcollection["Address"].ToString();
                searchcompany1.ZoneList        = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                searchcompany1.BillingRateList = db.BillingRates.Select(z => z).ToList();
                compinfo.UpdateDate            = DateTime.Now.Date;
                compinfo.Status                = frmcollection["Status"].ToString();
                compinfo.OwnershipType         = frmcollection["EditOwnershipType"].ToString();
                compinfo.EnterpriseType        = frmcollection["EnterpriseType"].ToString();
                compinfo.SendEmail             = frmcollection["SendEmail"].ToString();
                compinfo.PrimaryEmailAddress   = frmcollection["EmailAddress"].ToString();
                compinfo.SecondaryEmailAddress = frmcollection["SecondaryEmailAddress"].ToString();
                if (frmcollection["Vatable"].ToString() == "YES")
                {
                    compinfo.Vat          = 12;
                    compinfo.VatableItems = frmcollection["Vatable"].ToString();
                }
                else if (frmcollection["Vatable"].ToString() == "NO")
                {
                    compinfo.VatableItems = "NO";
                }
                else
                {
                    compinfo.VatableItems = "";
                }
                try
                {
                    compinfo.DateOfRegistration = Convert.ToDateTime(frmcollection["EditDateOfRegistration"].ToString());
                }
                catch { }
                if (searchcompany1.ZoneList.Count != 0)
                {
                    compinfo.ZoneCode = frmcollection["ZoneCode"].ToString();
                }
                try
                {
                    if (searchcompany1.BillingRateList.Count != 0)
                    {
                        compinfo.WithHolding = frmcollection["WithHolding"].ToString();
                    }
                }
                catch (Exception)
                {
                    //compinfo.VatableItems = null;
                    compinfo.WithHolding     = null;
                    db.Entry(compinfo).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                finally
                {
                    db.Entry(compinfo).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }
            else
            {
                Response.Write("<script> alert('Update Failed!') </script>");
                TempData["IsSuccess"] = false;
            }
            int           parsedCompanyID = int.Parse(frmcollection["CompanyID"]);
            SearchCompany searchcompany   = new SearchCompany();
            int           CompId          = Convert.ToInt32(frmcollection["CompanyID"]);

            //NewCompanies = db.Company.Select(x => x).OrderBy(x => x.CompanyName).Take(10).ToList();
            NewCompanies = db.Company.Where(x => x.CompanyID == CompId).ToList();
            SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);

            searchcompany.CompanyList      = searchCompanyPerGroup.Companies;
            searchcompany.ZoneList         = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
            TempData["IsSuccess"]          = true;
            TempData["TransactionSuccess"] = "Edit";
            TempData["searchcompany"]      = searchcompany;
            TempData["SelectedCompany"]    = "COMPHIDE";
            return(RedirectToAction("ViewCompany", "MaintenanceCompany"));
        }
        public async Task <ActionResult <IEnumerable <BranchOffices> > > SearchCompany(SearchCompany searchCompany)
        {
            List <BranchOffices> listOffice = new List <BranchOffices>();

            //var pom = context.Carcompanies.Include(x => x.BranchOffices).ToList();
            // var pom1 = context.BranchOffices.Include(x=>x.Id_company).ToList().SingleOrDefault(x => x.Name == searchCompany.ServiceName);
            // var pom1 = "";
            if (searchCompany.ServiceName != "" && searchCompany.Location == "")
            {
                if (context.Carcompanies.Include(x => x.BranchOffices).ToList().SingleOrDefault(x => x.Name.ToLower() == searchCompany.ServiceName.ToLower()) != null)
                {
                    var pom1 = context.Carcompanies.Include(x => x.BranchOffices).ToList().SingleOrDefault(x => x.Name.ToLower() == searchCompany.ServiceName.ToLower()).BranchOffices.ToList();
                    listOffice = pom1;
                }
                else
                {
                    listOffice = null;
                }
            }
            else if (searchCompany.ServiceName == "" && searchCompany.Location != "")
            {
                var pom = context.BranchOffices.ToList();

                var pom1 = pom.FindAll(x => x.City.ToLower() == searchCompany.Location.ToLower()).ToList();
                listOffice = pom1;
            }

            else if (searchCompany.ServiceName != "" && searchCompany.Location != "")
            {
                if (context.Carcompanies.Include(x => x.BranchOffices).ToList().SingleOrDefault(x => x.Name.ToLower() == searchCompany.ServiceName.ToLower()) != null)
                {
                    var pom1 = context.Carcompanies.Include(x => x.BranchOffices).ToList().SingleOrDefault(x => x.Name.ToLower() == searchCompany.ServiceName.ToLower()).BranchOffices.ToList();
                    var pom  = pom1.FindAll(x => x.City.ToLower() == searchCompany.Location.ToLower()).ToList();

                    listOffice = pom;
                }
                else
                {
                    listOffice = null;
                }
            }

            return(listOffice);
        }
        public ActionResult ViewCompany(string SearchInput, string Rate, FormCollection frm)
        {
            SearchCompany        searchcompany  = new SearchCompany();
            SearchCompany        searchcompany1 = new SearchCompany();
            ApplicationDbContext context        = new ApplicationDbContext();
            var    userid            = User.Identity.GetUserId();
            string ZoneGroup         = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            int    SingleZoneGroupId = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId;

            //Result of initial search button
            if (!string.IsNullOrEmpty(SearchInput))
            {
                searchcompany1.SearchInput = SearchInput.ToString();
                List <Company> NewCompanies = new List <Company>();
                NewCompanies = db.Company.Where(x => x.CompanyName.Contains(SearchInput)).ToList().OrderBy(x => x.CompanyName).ToList();
                SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                searchcompany1.CompanyList = searchCompanyPerGroup.Companies;
                searchcompany1.ZoneList    = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                ViewBag.SelectedCompany    = "COMPSHOW";
                return(View(searchcompany1));
            }
            //Result of selected company shown by "Search button"
            else if (frm.Count == 2)
            {
                int  OutParseValue;
                bool CanParse = int.TryParse(frm[1].ToString(), out OutParseValue);
                if (CanParse)
                {
                    int            ParsedCompanyID = int.Parse(frm[1].ToString());
                    List <Company> NewCompanies    = new List <Company>();
                    NewCompanies = db.Company.Where(m => m.CompanyID == ParsedCompanyID).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    searchcompany1.CompanyList = searchCompanyPerGroup.Companies;
                }
                var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                foreach (var item in bill)
                {
                    searchcompany1.Category.Add(item.Category);
                }
                searchcompany1.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                ViewBag.SelectedCompany = "COMPHIDE";
                return(View(searchcompany1));
            }
            //If returned key/value pairs is > 3. "Add transaction is invoked
            else if (frm.Count > 3)
            {
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Added Item! (Maintenance Company) - from Terminal:" + ipaddress);
                Company companyinfo = new Company();
                var     CompCode    = frm["CompanyCode"].ToString();
                companyinfo.CompanyCode        = frm["CompanyCode"].ToString();
                companyinfo.CompanyName        = frm["CompanyName"].ToString();
                companyinfo.Phase              = frm["Phase"].ToString();
                companyinfo.Address            = frm["Address"].ToString();
                companyinfo.CreateDate         = DateTime.Now.Date;
                companyinfo.Status             = frm["Status"].ToString();
                companyinfo.OwnershipType      = frm["OwnershipType"].ToString();
                companyinfo.EnterpriseType     = frm["EnterpriseType"].ToString();
                searchcompany1.ZoneList        = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                searchcompany1.BillingRateList = db.BillingRates.Select(z => z).ToList();

                var vat = frm["Vatable"].ToString();
                if (vat == "YES")
                {
                    companyinfo.VatableItems = "YES";
                    companyinfo.Vat          = 12;
                }
                else
                {
                    companyinfo.VatableItems = "NO";
                }
                try
                {
                    if (searchcompany1.ZoneList.Count != 0)
                    {
                        companyinfo.ZoneCode = frm["ZoneCode"].ToString();
                    }
                }
                catch
                {
                }
                try
                {
                    if (searchcompany1.BillingRateList.Count != 0)
                    {
                        companyinfo.WithHolding = frm["WithHolding"].ToString();
                    }
                }
                catch
                {
                }
                companyinfo.SendEmail             = frm["SendEmail"].ToString();
                companyinfo.PrimaryEmailAddress   = frm["AddEmailAddress"].ToString();
                companyinfo.SecondaryEmailAddress = frm["AddSecondaryEmailAddress"].ToString();
                try
                {
                    companyinfo.DateOfRegistration = Convert.ToDateTime(frm["DateOfRegistration"].ToString());
                }
                catch { }
                db.Company.Add(companyinfo);
                db.SaveChanges();

                var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                foreach (var item in bill)
                {
                    searchcompany.Category.Add(item.Category);
                }
                List <Company> NewCompanies = new List <Company>();
                NewCompanies = db.Company.Select(x => x).OrderByDescending(x => x.CompanyID).Take(50).ToList();
                SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                searchcompany.CompanyList      = searchCompanyPerGroup.Companies;
                searchcompany.ZoneList         = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                TempData["TransactionSuccess"] = "Add";
                TempData["searchcompany"]      = searchcompany;
                TempData["SelectedCompany"]    = "COMPHIDE";
                return(RedirectToAction("ViewCompany", "MaintenanceCompany"));
            }
            else
            {
                Response.Write("<script> alert('Invalid Transaction!') </script>");
            }
            //Default value
            //searchcompany.CompanyList = searchcompany.CompanyList.Select(x => x).ToList();
            return(View("ViewCompany"));
            //return View();
        }
Пример #19
0
        public ActionResult ViewRentals()
        {
            SearchCompany searchcompany = new SearchCompany();

            return(View(searchcompany));
        }
Пример #20
0
        public ActionResult ViewRentals(string SearchInput, FormCollection frm, RentalInformation rentalinfo, string isEdit)
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;

            var username = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.Rentals;
            //Result of initial search button
            if (!string.IsNullOrEmpty(SearchInput))
            {
                SearchCompany searchcompany1 = new SearchCompany();
                searchcompany1.SearchInput = SearchInput.ToString();
                List <Company> NewCompanies = new List <Company>();
                NewCompanies = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%'").ToList();
                SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                searchcompany1.CompanyList = searchCompanyPerGroup.Companies;
                //searchcompany1.CompanyList = db.Company.SqlQuery("Select * from Companies where CompanyName like '%" + SearchInput + "%' and ZoneGroup").ToList();

                ViewBag.CompanySelected = "";
                return(View(searchcompany1));
            }
            //Result of selected company shown by "Search button"
            else if (frm.Count == 2)
            {
                int           OutParseValue;
                bool          CanParse       = int.TryParse(frm[1].ToString(), out OutParseValue);
                SearchCompany searchcompany1 = new SearchCompany();

                if (CanParse)
                {
                    int ParsedCompanyID = int.Parse(frm[1].ToString());
                    searchcompany1.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == ParsedCompanyID).ToList();
                    searchcompany1.CompanyList           = db.Company.Where(m => m.CompanyID == ParsedCompanyID).ToList();
                    searchcompany1.BillingRate           = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList();

                    var bill = searchcompany1.BillingRate.GroupBy(m => m.SubCategory).ToList();
                    foreach (var item in bill)
                    {
                        searchcompany1.SubCategory.Add(item.Key.ToString());
                    }
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Search Company  - from Terminal: " + ipaddress);
                    ViewBag.CompanySelected = "OK";
                }
                else
                {
                    ViewBag.CompanySelected = "";
                }


                return(View(searchcompany1));
            }
            else if (isEdit == "True") //Edit transaction
            {
                var area    = frm["Area"].Split(',');
                var newArea = "";
                foreach (var item in area)
                {
                    newArea = newArea + item;
                }
                RentalInformation rent = new RentalInformation();
                int CompanyID          = int.Parse(frm["CompanyID"].ToString());
                //TryUpdateModel(rent);
                //if (ModelState.IsValid)
                //{
                RentalInformation rentinfo = null;
                int ParsedIntRentID        = int.Parse(frm["rentID"]);
                rentinfo = db.RentalInformation.Find(ParsedIntRentID);

                if (rentinfo != null)
                {
                    rentinfo.Type          = frm["Type"].ToString();
                    rentinfo.Rate          = decimal.Parse(frm["Rate"]);
                    rentinfo.Area          = Math.Round(decimal.Parse(newArea), 2);
                    rentinfo.Amount        = Math.Round(decimal.Parse(frm["Rate"]) * decimal.Parse(frm["Area"]), 2);
                    rentinfo.StartDate     = DateTime.Parse(frm["StartDate"].ToString());
                    rentinfo.EndDate       = DateTime.Parse(frm["EndDate"].ToString());
                    rentinfo.BillMode      = frm["BillMode"].ToString();
                    rentinfo.DueOn         = int.Parse(frm["DueOn"]);
                    rentinfo.BillingMonths = frm["billingMonths"];
                    //rentinfo.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12";
                    rentinfo.Currency        = frm["Currency"].ToString();
                    rentinfo.UpdateDate      = DateTime.Now;
                    rentinfo.UpdatedBy       = userid;
                    db.Entry(rentinfo).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    ViewBag.ValidatePostback = "True";
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Edit  - from Terminal: " + ipaddress);
                    TempData["TransactionSuccess"] = "Edit";
                    //ViewBag.TransactionSuccess = "Edit";
                }
                //}
                else
                {
                    ViewBag.ValidatePostback = "False";
                }

                SearchCompany searchcompany = new SearchCompany();
                searchcompany.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == CompanyID).ToList();
                searchcompany.CompanyList           = db.Company.Where(m => m.CompanyID == CompanyID).ToList();
                searchcompany.BillingRate           = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList();

                var bill = searchcompany.BillingRate.GroupBy(m => m.SubCategory).ToList();

                foreach (var item in bill)
                {
                    searchcompany.SubCategory.Add(item.Key);
                }
                ViewBag.CompanySelected = "OK";

                TempData["SearchCompany"] = searchcompany;
                return(RedirectToAction("ViewRentalsRPG", "DataEntryRental"));
                //return View(searchcompany);
            }
            //If returned key/value pairs is > 3. "Add transaction is invoked
            else if (frm.Count > 3)
            {
                int     OutIntParse;
                decimal OutDecimalParse;
                bool    canParse        = int.TryParse(frm["CompanyID"].ToString(), out OutIntParse);
                int     parsedCompanyID = (canParse) ? int.Parse(frm["CompanyID"].ToString()) : 0;
                //int ParsedIntRentID = int.Parse(frm["RentalInformationId"]);
                RentalInformation rent = new RentalInformation();
                TryUpdateModel(rent);
                //var errors = ModelState.Values.SelectMany(v => v.Errors);
                //UpdateModel<IRentalInformation>(rent);
                //if (ModelState.IsValid)
                //{
                try
                {
                    var r       = frm["Rate"].ToString();
                    var s       = r.Split(',');
                    var newRate = "";
                    foreach (var item in s)
                    {
                        newRate += item;
                    }
                    decimal rate = Math.Round((decimal.TryParse(newRate, out OutDecimalParse)) ? decimal.Parse(newRate) : 0, 2);
                    decimal area = Math.Round((decimal.TryParse(frm["Area"].ToString(), out OutDecimalParse)) ? decimal.Parse(frm["Area"].ToString()) : 0, 2);
                    decimal amt  = Math.Round(rate * area, 2);

                    int RentalBillMode = (int.TryParse(frm["BillMode"].ToString(), out OutIntParse)) ? int.Parse(frm["BillMode"].ToString()) : 0;

                    RentalInformation rentalinformation = new RentalInformation();

                    rentalinformation.CompanyId = parsedCompanyID;
                    rentalinformation.Type      = frm["Type"].ToString();
                    rentalinformation.Rate      = rate;
                    rentalinformation.Area      = area;

                    string str = frm["StartDate"].ToString();

                    rentalinformation.StartDate = Convert.ToDateTime(frm["StartDate"].ToString());
                    rentalinformation.EndDate   = Convert.ToDateTime(frm["EndDate"].ToString());
                    //rentalinformation.BillMode = (int.TryParse(frm["BillMode"].ToString(), out OutIntParse)) ? int.Parse(frm["BillMode"].ToString()) : 0;
                    rentalinformation.BillMode = frm["BillMode"].ToString();
                    rentalinformation.DueOn    = (int.TryParse(frm["DueOn"].ToString(), out OutIntParse)) ? int.Parse(frm["DueOn"].ToString()) : 0;

                    rentalinformation.BillingMonths = frm["billingMonths"];
                    //rentalinformation.BillingMonths = "1,2,3,4,5,6,7,8,9,10,11,12";
                    rentalinformation.CreatedDate = DateTime.Now;
                    rentalinformation.Amount      = amt;
                    rentalinformation.Currency    = frm["Currency"].ToString();
                    rentalinformation.CreatedBy   = userid;

                    db.RentalInformation.Add(rentalinformation);
                    db.SaveChanges();
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Rental - Add - from Terminal: " + ipaddress);
                    TempData["TransactionSuccess"] = "Add";
                    //ViewBag.TransactionSuccess = "Add";
                    ViewBag.ValidatePostback = "True";
                }
                catch (Exception)
                {
                    ViewBag.ValidatePostback = "False";
                }
                //}
                //else
                //{
                //    ViewBag.ValidatePostback = "False";
                //}


                ViewBag.CompanySelected = "OK";
                SearchCompany searchcompany = new SearchCompany();
                searchcompany.RentalInformationList = db.RentalInformation.Where(m => m.CompanyId == parsedCompanyID).ToList();
                searchcompany.CompanyList           = db.Company.Where(m => m.CompanyID == parsedCompanyID).ToList();
                searchcompany.BillingRate           = db.BillingRates.Where(m => m.Category == "Rental Fee").Where(m => m.ZoneGroup == ZoneGroup).ToList();

                var bill = searchcompany.BillingRate.GroupBy(m => m.SubCategory).ToList();

                foreach (var item in bill)
                {
                    searchcompany.SubCategory.Add(item.Key);
                }

                TempData["SearchCompany"] = searchcompany;
                return(RedirectToAction("ViewRentalsRPG", "DataEntryRental"));
                //return View(searchcompany);
            }
            //Default value
            else
            {
                SearchCompany searchcompany1 = new SearchCompany();
                return(View(searchcompany1));
            }
        }
        public TutorialQuery(ICompanyService companyService)
        {
            #region Company

            Field <CompanyGraphType>(
                name: "company",
                arguments: new QueryArguments(new List <QueryArgument>
            {
                new QueryArgument <IntGraphType>
                {
                    Name = "companyId"
                },
                new QueryArgument <StringGraphType>
                {
                    Name = "companyName"
                },
                new QueryArgument <BooleanGraphType>
                {
                    Name = "isActive"
                }
            }),
                resolve : delegate(ResolveFieldContext <object> context)
            {
                var columns = context.GetMainSelectedFields();

                var companyId   = context.GetArgument <int?>("companyId");
                var companyName = context.GetArgument <string>("companyName");
                var isActive    = context.GetArgument <bool?>("isActive");

                var request = new SearchCompany
                {
                    Id       = companyId,
                    Name     = companyName,
                    IsActive = isActive,
                    Columns  = columns
                };
                return(companyService.GetCompany(request));
            });

            Field <ListGraphType <CompanyGraphType> >(
                "companies",
                arguments: new QueryArguments(new List <QueryArgument>
            {
                new QueryArgument <ListGraphType <IntGraphType> >
                {
                    Name = "companyIds"
                },
                new QueryArgument <ListGraphType <StringGraphType> >
                {
                    Name = "companyNames"
                },
                new QueryArgument <BooleanGraphType>
                {
                    Name = "isActive"
                },
                new QueryArgument <IntGraphType>
                {
                    Name = "page"
                },
                new QueryArgument <IntGraphType>
                {
                    Name = "pageSize"
                }
            }),
                resolve : delegate(ResolveFieldContext <object> context)
            {
                var columns      = context.GetMainSelectedFields();
                var companyIds   = context.GetArgument <int?[]>("companyIds");
                var companyNames = context.GetArgument <string[]>("companyNames");
                var isActive     = context.GetArgument <bool?>("isActive");

                var page     = context.GetArgument <int?>("page");
                var pageSize = context.GetArgument <int?>("pageSize");

                var request = new SearchCompanies()
                {
                    Ids      = companyIds,
                    Names    = companyNames,
                    IsActive = isActive,
                    Page     = page,
                    PageSize = pageSize,
                    Columns  = columns
                };
                return(companyService.GetCompanies(request));
            });

            #endregion
        }
        // Search / Filter Company
        public ActionResult ViewSelectFilter(FormCollection frm)
        {
            ApplicationDbContext context           = new ApplicationDbContext();
            var            userid                  = User.Identity.GetUserId();
            string         ZoneGroup               = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            int            SingleZoneGroupId       = db.ZoneGroup.FirstOrDefault(d => d.ZoneGroupCode == ZoneGroup).ZoneGroupId;
            SearchCompany  SearchCompanyViewModels = new SearchCompany();
            List <Company> NewCompanies            = new List <Company>();

            if (frm.Count >= 1)
            {
                if (frm["SelectFilter"] == "All")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched all items! (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Select(x => x).OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Service Enterprise")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Service Enterprise (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Service Enterprise").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Logistics")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Logistics (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Logistics").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Utilities")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Utilities (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Utilities").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Regional Warehouse")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Warehouse (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Regional Warehouse").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Export Enterprise")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Export Enterprise (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Export Enterprise").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Domestic Market")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Domestic Market (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Domestic Market").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "IT Enterprise")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by IT Enterprise (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "IT Enterprise").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Facilities Enterprise")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Facilities Enterprise (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Facilities Enterprise").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Tourism Enterprise")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Tourism Enterprise (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Tourism Enterprise").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Agro-Industrial")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Agro-Industrial (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Agro-Industrial").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Developer Enterprise")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Developer Enterprise (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Developer Enterprise").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Free Trade")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Free Trade (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Free Trade").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Medical Tourism")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Medical Tourism (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Medical Tourism").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "PEZA Employees/Tenants")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by PEZA Employees/Tenants (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "PEZA Employees/Tenants").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else if (frm["SelectFilter"] == "Unknown")
                {
                    SL.LogInfo(User.Identity.Name, Request.RawUrl, "User searched items filtered by Unknown (Maintenance Company) - from Terminal:" + ipaddress);
                    NewCompanies = db.Company.Where(x => x.EnterpriseType == "Unknown").OrderBy(x => x.CompanyName).ToList();
                    SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(NewCompanies, ZoneGroup);
                    SearchCompanyViewModels.CompanyList     = searchCompanyPerGroup.Companies;
                    SearchCompanyViewModels.BillingRateList = db.BillingRates.SqlQuery("Select Distinct * from BillingRates").ToList();
                    var bill = db.BillingRates.GroupBy(m => m.Category).Select(g => new { Category = g.Key }).ToList();
                    foreach (var item in bill)
                    {
                        SearchCompanyViewModels.Category.Add(item.Category);
                    }
                    ViewBag.SelectedCompany          = "COMPSHOW";
                    SearchCompanyViewModels.ZoneList = db.Zone.Where(x => x.ZoneGroup == SingleZoneGroupId.ToString()).ToList();
                }
                else
                {
                    return(View());
                }
            }
            return(View("ViewCompany", SearchCompanyViewModels));
        }
Пример #23
0
        static TokenComboBoxEdit()
        {
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MovieMatrix.Assets.Data.AutoSuggestData.zip"))
            {
                using (ZipArchive archive = new ZipArchive(stream))
                {
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        if (entry.Name == "Companies.txt")
                        {
                            List <SearchCompany> companies = new List <SearchCompany>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    SearchCompany company = JsonConvert.DeserializeObject <SearchCompany>(line);
                                    companies.Add(company);
                                }
                            }

                            Companies = new ObservableCollection <SearchCompany>(companies);
                        }
                        else if (entry.Name == "Keywords.txt")
                        {
                            List <SearchKeyword> keywords = new List <SearchKeyword>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    SearchKeyword keyword = JsonConvert.DeserializeObject <SearchKeyword>(line);
                                    keywords.Add(keyword);
                                }
                            }

                            Keywords = new ObservableCollection <SearchKeyword>(keywords);
                        }
                        else if (entry.Name == "Networks.txt")
                        {
                            List <Network> networks = new List <Network>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    Network network = JsonConvert.DeserializeObject <Network>(line);
                                    networks.Add(network);
                                }
                            }

                            Networks = new ObservableCollection <Network>(networks);
                        }
                        else if (entry.Name == "People.txt")
                        {
                            List <SearchPerson> people = new List <SearchPerson>();
                            using (StreamReader reader = new StreamReader(entry.Open()))
                            {
                                string line = String.Empty;
                                while ((line = reader.ReadLine()) != null)
                                {
                                    SearchPerson person = JsonConvert.DeserializeObject <SearchPerson>(line);
                                    people.Add(person);
                                }
                            }

                            People = new ObservableCollection <SearchPerson>(people);
                        }
                    }
                }
            }
        }
Пример #24
0
 public ActionResult Search(SearchCompany searchcompany)
 {
     Session["SearchInput"] = searchcompany.SearchInput;
     return(RedirectToAction("List", "SearchCompany"));
     //return View();
 }