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);
        }
        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);
        }
        public List <OfferedLabourerService> ParsePursToOls()
        {
            string pur       = this.HttpContext.Session.GetString("PUR");
            string purs      = pur.Substring(1);
            char   separator = ' ';

            string[] orderIds = purs.Split(separator);

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

            foreach (string id in orderIds)
            {
                int olsId = Convert.ToInt32(id);
                olsList.Add(EsOLSQuery <OfferedLabourerService> .findByOfferedServiceId(olsId));
            }
            return(olsList);
        }
Beispiel #4
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));
        }
        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());
            }
        }
        public List <OfferedLabourerService> ParseOrdersToOLS()
        {
            //Add exception handler!
            string orders    = this.HttpContext.Session.GetString("ORD").Substring(1);
            char   separator = ' ';

            string[] orderIds = orders.Split(separator);

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

            double cost = olsList.Sum(s => s.fld_cost);

            foreach (string id in orderIds)
            {
                int olsId = Convert.ToInt32(id);
                olsList.Add(EsOLSQuery <OfferedLabourerService> .findByOfferedServiceId(olsId));
            }
            return(olsList);
        }