Ejemplo n.º 1
0
        public ActionResult Index(DTOSearch Obj)
        {
            DTOSearch result;

            if (Obj.SearchField == null)
            {
                result = new DTOSearch
                {
                    DTOEmployeesTable = new ApiEmployeeController().Get()
                };
            }
            else
            {
                int  id        = 0;
                bool isInteger = Int32.TryParse(Obj.SearchField, out id);
                if (isInteger)
                {
                    result = new DTOSearch
                    {
                        DTOEmployeesTable = new ApiEmployeeController().Get(id),
                        SearchField       = Obj.SearchField
                    };
                }
                else
                {
                    result = new DTOSearch {
                        DTOEmployeesTable = new ApiEmployeeController().Get(),
                    };
                }
            }

            return(View(result));
        }
Ejemplo n.º 2
0
        // GET: Employees
        public ActionResult Index()
        {
            DTOSearch result = new DTOSearch
            {
                DTOEmployeesTable = new ApiEmployeeController().Get()
            };

            return(View(result));
        }
Ejemplo n.º 3
0
        public async Task <DTOCompatablity> SearchCompatablity(DTOSearch search)
        {
            var carrier = await _dbContext.Carriers.FirstOrDefaultAsync(r => search.Country.Equals(r.Country) && search.CarrierName.Equals(r.CarrierName));

            var device = await _dbContext.Devices
                         .FirstOrDefaultAsync(r => search.Brand.Equals(r.Brand) && search.PhoneModel.Equals(r.PhoneModel) &&
                                              (string.IsNullOrWhiteSpace(search.SubModel) || r.SubModel.Equals(search.SubModel)));

            var dtoCarrier = _mapper.Map <DTOCarrier>(carrier);
            var dtoDevice  = _mapper.Map <DTODevice>(device);

            // Compatablity Info = CI
            var ci = new DTOCompatablity();

            ci.CarrierFrequencies = new DTONetwork()
            {
                Two_G   = dtoCarrier.Two_G,
                Three_G = dtoCarrier.Three_G,
                Four_G  = dtoCarrier.Four_G,
                Five_G  = dtoCarrier.Five_G,
            };

            ci.DeviceFrequencies = new DTONetwork()
            {
                Two_G   = dtoDevice.Two_G,
                Three_G = dtoDevice.Three_G,
                Four_G  = dtoDevice.Four_G,
                Five_G  = dtoDevice.Five_G,
            };

            // Two G
            ci.TwoGFullCompatible = Utility.CompareResults(ci.CarrierFrequencies.Two_G, ci.DeviceFrequencies.Two_G, "2G", out Tuple <int, string> result2G);
            ci.TwoGMatchedFreq    = result2G.Item1;
            ci.Two_G = result2G.Item2;

            // Three G
            ci.ThreeGFullCompatible = Utility.CompareResults(ci.CarrierFrequencies.Three_G, ci.DeviceFrequencies.Three_G, "3G", out Tuple <int, string> result3G);
            ci.ThreeGMatchedFreq    = result3G.Item1;
            ci.Three_G = result3G.Item2;

            // Four G
            ci.FourGFullCompatible = Utility.CompareResults(ci.CarrierFrequencies.Four_G, ci.DeviceFrequencies.Four_G, "4G", out Tuple <int, string> result4G);
            ci.FourGMatchedFreq    = result4G.Item1;
            ci.Four_G = result4G.Item2;

            // Five G
            ci.FiveGFullCompatible = Utility.CompareResults(ci.CarrierFrequencies.Five_G, ci.DeviceFrequencies.Five_G, "5G", out Tuple <int, string> result5G);
            ci.FiveGMatchedFreq    = result5G.Item1;
            ci.Five_G = result5G.Item2;

            return(ci);
        }
Ejemplo n.º 4
0
 public DTOSearchResult SearchWord(DTOSearch word)
 {
     if (word != null)
     {
         PuzzleModel puzzle = new PuzzleModel();
         puzzle.FillPuzzle(word.puzzle.Select(E => string.Concat(E)).ToList());
         var             z      = puzzle.ContainsWord(word.word);
         DTOSearchResult result = new DTOSearchResult()
         {
             Word = word.word, Breakdown = z.Reverse().ToList()
         };
         return(result);
     }
     return(null);
 }
Ejemplo n.º 5
0
 public DTOSearchResult SearchWord([FromBody] DTOSearch word)
 {
     try
     {
         PuzzleService service = new PuzzleService();
         return(service.SearchWord(word));
     }
     catch (Exception)
     {
         return(new DTOSearchResult()
         {
             Breakdown = new List <LettersModel>(), Word = string.Empty
         });
     }
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> SearchCompatablity([FromQuery] DTOSearch search)
        {
            var model = await _repo.SearchCompatablity(search);

            return(Ok(model));
        }
Ejemplo n.º 7
0
        public ActionResult RoomsSearch(DTOSearch det, int?categoryId)
        {
            DateTime date = DateTime.Today;

            if (date <= det.Arival_Date)
            {
                //make object of view model
                RoomViewModel RVM = new RoomViewModel();
                //make categorys
                RVM.catogories = db.Room_Catagorys.Where(c => c.IsActive == true).ToList();

                // var reservedRooms = db.RoomBookings.Where(r => r.ArivalDate <= det.Arival_Date && r.DepartureDate >= det.Departure_Date).Select(b => b.RoomNo).Distinct().ToList();
                var reservedRooms        = db.RoomBookings.Where(r => !(r.ArivalDate >= det.Departure_Date) && !(r.DepartureDate <= det.Arival_Date)).Select(v => v.RoomNo).Distinct().ToList();
                IEnumerable <Room> rooms = db.Rooms.Where(a => !reservedRooms.Contains(a.Room_Number)).ToList();

                int total = det.Adults + det.Childerens;
                IEnumerable <Room> FreeRooms = rooms.Where(a => a.RoomCapacity >= total).ToList();

                Session["FreeRooms"] = FreeRooms;

                var freeRooms = ((IEnumerable <Room>)Session["FreeRooms"]);
                RVM.RoomList = freeRooms;

                Guest_Details Guest = new Guest_Details();
                Guest = ((Guest_Details)Session["logindetails"]);
                if (Guest != null)
                {
                    ViewBag.Name = Guest.Guest_First_Name;
                }

                //if (categoryId.HasValue && categoryId != null)
                //{
                //    RVM.RoomList = freeRooms.Where(i => i.Room_Category_Id == categoryId).ToList();
                //}
                //else
                //{
                //    RVM.RoomList = freeRooms;
                //}

                // IEnumerable<RoomBooking> se=   db.RoomBookings.Where((x => x.ArivalDate <= det.Arival_Date && x.DepartureDate<=det.Arival_Date) ||(y=>y.));
                //IEnumerable<RoomBooking> se = from r in db.RoomBookings where(r =>r.ArivalDate <= det.Arival_Date && r.DepartureDate <= det.Arival_Date) select r;
                //from x in db.RoomBookings where (x.ArivalDate >= det.Departure_Date && x.DepartureDate >= det.Departure_Date)) select x;
                //IEnumerable<RoomBooking> one = db.RoomBookings.Where(r => r.ArivalDate <= det.Arival_Date && r.DepartureDate <= det.Arival_Date).ToList();
                //IEnumerable<RoomBooking> two = db.RoomBookings.Where(y => y.ArivalDate >= det.Departure_Date && y.DepartureDate >= det.Departure_Date).ToList();
                //  IEnumerable<RoomBooking> set = db.RoomBookings.ToList().Where(r => r.ArivalDate <= det.Arival_Date && r.DepartureDate <= det.Arival_Date).Where(y => y.ArivalDate >= det.Departure_Date && y.DepartureDate >= det.Departure_Date);
                // var swet = db.RoomBookings.Where(r => r.ArivalDate > det.Departure_Date || r.DepartureDate < det.Arival_Date).Select(b=>b.RoomNo).Distinct().ToList();


                //var reservedRooms = db.RoomBookings.
                //    Where(r => r.ArivalDate <= det.Arival_Date && r.DepartureDate >= det.Departure_Date).
                //    Select(b => b.RoomNo).Distinct().ToList();



                //var rooms=  db.Rooms.Where(a =>!reservedRooms.Contains(a.Room_Number)).ToList();
                //RVM.RoomList = rooms;
                //r.DepartureDate <= det.Arival_Date).ToList();
                //IEnumerable<RoomBooking> sweot = db.RoomBookings.Where(r => r.ArivalDate >= det.Departure_Date).ToList();
                //IEnumerable<RoomBooking> sweoit = db.RoomBookings.Where(r => r.DepartureDate <= det.Arival_Date).ToList();

                //IEnumerable<Room> roomsa = db.Rooms.Where(a => !test.Contains(a.Room_Number)).ToList();
                //IEnumerable<RoomBooking> sweoait = sweot.Concat(sweoit).ToList();

                //var NILL = db.RoomBookings.Where(r => r.ArivalDate >= det.Arival_Date && r.DepartureDate <= det.Departure_Date ||
                //r.ArivalDate >= det.Arival_Date && r.DepartureDate >= det.Departure_Date ||
                //r.ArivalDate < det.Arival_Date && r.DepartureDate <= det.Departure_Date ||
                //r.ArivalDate <= det.Arival_Date && r.DepartureDate >= det.Departure_Date).Select(b => b.RoomNo).Distinct().ToList();


                //foreach (RoomBooking item in se)
                //{
                //    int? NOS = item.RoomNo;
                //}
                // var ee= sweoait.GroupBy(test1 => test1.RoomNo).Select(grp => grp.First()).ToList();



                //IEnumerable <Room> rrr = from r in db.Rooms join b in ee on r.Room_Number equals b.RoomNo into joinDeptEmp select new { name = r.Room_Category_Id });
                // RVM.RoomList = rrr;
                //int cap = det.Adults + det.Childerens;
                //IEnumerable<Room> tt =(from m in db.Rooms where (!(m.Check_In_Date >= det.Arival_Date && m.Check_Out_Date <= det.Departure_Date) && m.RoomCapacity >= cap) select m).ToList();
                //RoomViewModel rooms = new RoomViewModel();
                //rooms.RoomList = tt;


                return(View(RVM));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 8
0
        public static void ParseQuery(out String queryText, out Object[] parameterArray, out String orderBy, out String descending, DTOSearch searchObject)
        {
            var searchQuery = new StringBuilder(); //return querytext
            var parameters  = new List <Object>(); //return paramaterArray
            var filterCount = 0;                   //counter for the filters. increment for each filter added to the query

            if (searchObject.Queries != null)      //check if queries is not null
            {
                //loop to the queries
                foreach (var query in searchObject.Queries.Where(q => q.Filters != null && q.Filters.Count > 0))
                {
                    searchQuery.Append("(");  //enclose all query into a parenthesis

                    var addedFilterCount = 0; //counter for the added filter. used for checking if we are on the last filter.

                    foreach (var item in query.Filters.Where(f => !String.IsNullOrWhiteSpace(f.ParameterName)))
                    {
                        if (item.Operator == Operators.Like) //different query format for the like condition
                        {
                            searchQuery.Append(String.Format("{0}.{1}(@{2}) ", item.ParameterName, item.Operator, filterCount));
                        }
                        else //if not like then do this formay
                        {
                            searchQuery.Append(String.Format("{0} {1} @{2} ", item.ParameterName, item.Operator, filterCount));
                        }

                        if (++addedFilterCount == query.Filters.Count) //enclose the query if we are on the last filter
                        {
                            searchQuery.Append(")");
                        }

                        searchQuery.Append(item.EndOperator); //add end operator if there are additional condition

                        parameters.Add(item.ParameterValue);  //add parameters

                        filterCount++;                        //increment filter count for each added filter
                    }
                }
            }


            queryText = searchQuery.ToString();    //return querytext

            parameterArray = parameters.ToArray(); //return parameters

            //if Orderby does not contain a value and search object contains a filter, use that filter for the orderby clause
            if (searchObject.PageNo > 0 && String.IsNullOrWhiteSpace(searchObject.SortColumn) && searchObject.Queries.Count > 0 && searchObject.Queries.FirstOrDefault().Filters.Count > 0)
            {
                orderBy = searchObject.Queries.FirstOrDefault().Filters.FirstOrDefault().ParameterName;
            }
            else
            {
                orderBy = searchObject.SortColumn;
            }

            if (searchObject.Descending)
            {
                descending = " DESC";
            }
            else
            {
                descending = "";
            }
        }