コード例 #1
0
        public static OfferedLabourerService findByOfferedServiceId(int id)
        {
            _connectionToEs = new ConnectionToES();
            var client = _connectionToEs.EsClient();


            Nest.ISearchResponse <OfferedLabourerService> response = client.Search <OfferedLabourerService>(s => s
                                                                                                            .Index("moll_ols")
                                                                                                            .Type("OLS")
                                                                                                            .Size(1)
                                                                                                            .Query(q => q
                                                                                                                   .Match(m => m
                                                                                                                          .Field(f => f.fld_offeredserviceid)
                                                                                                                          .Query(id.ToString())
                                                                                                                          )
                                                                                                                   )
                                                                                                            );

            var datasend = (from hits in response.Hits
                            select hits.Source).ToList();

            OfferedLabourerService package = (OfferedLabourerService)response.Documents.ElementAt(0);

            package.fld_cost = package.fld_cost / 100;

            return(package);
        }
コード例 #2
0
        public OfferedLabourerService UpdateOLS(string insertedDic)
        {
            tbl_offeredservicesdata currentOffer = JsonConvert.DeserializeObject <tbl_offeredservicesdata>(insertedDic);

            MollShopContext.UpdateRow(currentOffer, "fld_offeredserviceid", currentOffer.fld_offeredserviceid);

            //Because ElasticSearch does not support decimal numbers, we must multiply the cost by a 100
            currentOffer.fld_cost = currentOffer.fld_cost * 100;

            OfferedLabourerService currentOLS = EsOLSQuery <OfferedLabourerService> .findByOfferedServiceId(currentOffer.fld_offeredserviceid);

            currentOLS.fld_cost           = currentOffer.fld_cost;
            currentOLS.fld_area           = currentOffer.fld_area;
            currentOLS.fld_timefirst      = currentOffer.fld_timefirst;
            currentOLS.fld_timelast       = currentOffer.fld_timelast;
            currentOLS.fld_stillavailable = currentOffer.fld_stillavailable;



            EsUpdater <OfferedLabourerService> .UpsertDocument(currentOLS, "moll_ols", "OLS", currentOLS.fld_offeredserviceid);

            //To render it correctly in the datatable, we divice the cost by 100 again
            currentOLS.fld_cost = currentOLS.fld_cost / 100;

            return(currentOLS);
        }
コード例 #3
0
        public static List <OfferedLabourerService> fetchItemsInCookies(List <string> keyList)
        {
            List <OfferedLabourerService> packageList = new List <OfferedLabourerService>();

            foreach (string key in keyList)
            {
                int offeredServiceId = Convert.ToInt32(key.Substring(2));

                OfferedLabourerService ols = EsOLSQuery <string> .findByOfferedServiceId(offeredServiceId);

                packageList.Add(ols);
            }
            return(packageList);
        }
コード例 #4
0
        public IActionResult Details(OfferedLabourerService package)
        {
            tbl_labourerdata labourer = new tbl_labourerdata();

            labourer.fld_address     = package.fld_address;
            labourer.fld_dateofbirth = package.fld_dateofbirth.ToString();
            labourer.fld_email       = package.fld_email;
            labourer.fld_firstname   = package.fld_email;
            labourer.fld_gender      = package.fld_gender;
            labourer.fld_labourerid  = package.fld_labourerid;
            labourer.fld_lastname    = package.fld_lastname;
            labourer.fld_phonenumber = package.fld_phonenumber;
            labourer.fld_zipcode     = package.fld_zipcode;

            return(View("Details", labourer));
        }
コード例 #5
0
        public IActionResult MyOrders()
        {
            //Get the orders bound to the current userId
            //The email
            string userEmail = this.HttpContext.Session.GetString("User");

            //tbl_orders
            Dictionary <string, object> dic = new Dictionary <string, Object>();

            dic.Add("in_givenEmail", userEmail);
            List <Order> orders = ProcedureCall <Order> .returnResultList(dic, "util_GetOrders");

            //Instantiate lists
            List <List <tbl_orderhistory> > orderHistories = new List <List <tbl_orderhistory> >();

            List <tbl_orderstatus> orderStatuses = new List <tbl_orderstatus>();

            List <OfferedLabourerService> olsList = new List <OfferedLabourerService>();


            //Get all the relevant data
            for (int i = 0; i < orders.Count; i++)
            {
                Dictionary <string, Object> dic2 = new Dictionary <string, Object>();
                dic2.Add("in_orderid", orders[i].fld_OrderId);
                //tbl orderhistory
                List <tbl_orderhistory> orderhistories = ProcedureCall <tbl_orderhistory> .returnResultList(dic2, "util_GetOrderHistories").OrderByDescending(s => s.fld_ActionDate).ToList();

                //tbl_orderstatus
                tbl_orderstatus orderstatus = ProcedureCall <tbl_orderstatus> .ExecuteReader(dic2, "util_GetOrderStatuses");

                //tbl_offeredlabourerservice
                OfferedLabourerService ols = EsOLSQuery <OfferedLabourerService> .findByOfferedServiceId(orders[i].fld_OfferedServiceId);

                //Add it all to their respectiv lists
                orderStatuses.Add(orderstatus);
                olsList.Add(ols);
                orderHistories.Add(orderhistories);
            }


            Tuple <List <Order>, List <tbl_orderstatus>, List <List <tbl_orderhistory> >, List <OfferedLabourerService> > tuple = Tuple.Create(orders, orderStatuses, orderHistories, olsList);

            return(View(tuple));
        }
コード例 #6
0
        public IActionResult AddToFavourites(int fld_offeredserviceid)
        {
            CookieOptions options = new CookieOptions();

            options.Expires = DateTime.Now.AddSeconds(200);

            //De message die we de user geven gaat afhangen van de volgende try catch blokken:

            try
            {
                //De key voor de cookie
                string currentKey = "FL" + fld_offeredserviceid;
                //Check eerst of de service al in de favorites zit
                int sameKey = Request.Cookies.Keys.Count(k => k.Equals(currentKey));
                if (sameKey > 0)
                {
                    //Service zit al in favorites. Doe niets
                    ViewBag.FLResultMessage = "<p>Again?</p>";
                    return(View());
                }
                //Service zit nog niet in favorites
                Response.Cookies.Append(currentKey, "1", options);
                //Response.WriteAsync("<script>alert('test')</script>");

                ViewBag.FLResultMessage = "<p>Success!</p>";

                //Update the OLS in ElasticSearch
                OfferedLabourerService ols = EsOLSQuery <OfferedLabourerService> .findByOfferedServiceId(fld_offeredserviceid);

                ols.fld_addedtowishlist = ols.fld_addedtowishlist + 1;

                //Because ElasticSearch does not support decimal numbers, we must multiply the cost by a 100
                ols.fld_cost = ols.fld_cost * 100;
                ElasticSearch.EsUpdater <OfferedLabourerService> .UpsertDocument(ols, "moll_ols", "OLS", fld_offeredserviceid);

                return(View());
            }
            catch (Exception e)
            {
                ViewBag.FLResultMessage = "<p>Success!</p>";

                return(View());
            }
        }