public IActionResult Index()
        {
            //Return alle Labourers in een List
            MollShopContext context = HttpContext.RequestServices.GetService(typeof(TestWebApp.Models.MollShopContext)) as MollShopContext;

            return(View(context.GetAllLabourers()));
        }
        public void SendVerificationLink(string verificationToken, string emailAddress)
        {
            //Send verification link via email
            int    userId      = MollShopContext.FindUserIdByEmail(emailAddress);
            string messageBody = @"<body style='box-sizing: border-box;font-family: &quot;Lato&quot;, &quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Tahoma, Sans-Serif;width: auto;height: 100vw;margin: 0 0 0 0;'>
    <div id='section_form' style='box-sizing: border-box;background: #f4f4f4;padding-top: 2vw;padding-bottom: 5vw;'>
        <img id='circlelogo' src='https://i.imgur.com/lrkjNdQ.png' style='box-sizing: border-box;width: 8vw;height: auto;margin: auto;display: block;position: relative;top: 20px;z-index: 999;'>
        <div id='rectangle' style='box-sizing: border-box;;width: 40vw;height: auto;background: white;padding: 30px;margin: auto;border-radius: 30px;z-index: 950;'>

            <div class='registrationform' style='box-sizing: border-box;'>
                <table style='box-sizing: border-box;border: 0px solid #ffac35;margin: auto;text-align: center;font-size: 16px;margin-top: 20px;'>
                    <tbody style='box-sizing: border-box;'>
                        <tr style='box-sizing: border-box;'>
                            <td style='box-sizing: border-box;'>
                                <p style='box-sizing: border-box;color: #666666;font-size: 27px;font-weight: 700;font-family: &quot;Lato&quot;, &quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Tahoma, Sans-Serif;margin-bottom: 5%;'>Click the link below to verify your account!</p>
                            </td>
                        </tr>

                        <tr style='box-sizing: border-box;'>
                            <td style='box-sizing: border-box;'>" +
                                 "<a href =\"https://localhost:44346/Account/VerifyAccount?token=" + verificationToken + "&userid=" + userId + "\"><button style='box-sizing: border-box;background-color: #ffac35;color: white;padding: 10px 10px;border: none;cursor: pointer;opacity: 0.9;width: 220px;height: 100px;font-size: 25px;font-weight: 700;border-radius: 7px;-moz-transition: all 0.2s ease 0s;-o-transition: all 0.2s ease 0s;transition: all 0.2s ease 0s;margin: 0 auto;text-align: center;'>VERIFY NOW</button> </a>" +

                                 "";
            string subject = "Verify your account";

            MollShopContext.SendEmail(emailAddress, subject, messageBody);
        }
        //This Action is called from the initial shopping cart page
        //The user will click this when they are ready to purchase their products
        //It will return 1 of 2 views, depending on the users' login status
        public IActionResult PaymentAuthentication(string orders)
        {
            //First check if there are any orders. If not, nothing should happen. Refresh the page
            if (orders == null)
            {
                return(RedirectToAction("ShoppingCart", "ShoppingCart"));
            }

            //Retrieve the user status to check whether the user is logged in or not
            UserStatusModel userStatus = SessionController.CheckLoggedInStatus(this.HttpContext);

            //Put the orders in the browser session. This refreshes the list, so if the user has altered their shopping cart, it'll always be up to date when entering the ordering sequence
            SessionController.refreshOrderList(orders, this.HttpContext);



            if (userStatus.LoggedIn)
            {
                //User is logged in already, so return the PaymentMethod view
                List <OfferedLabourerService> olsList = ParseOrdersToOLS();

                tbl_userdata user = MollShopContext.FindUserById((int)this.HttpContext.Session.GetInt32("UserId"));
                Tuple <List <OfferedLabourerService>, tbl_userdata> tuple = Tuple.Create(olsList, user);

                return(View("OrderSpecification", tuple));
            }

            else
            {
                //User is not logged in. return the PaymentAuthentication view
                return(View());
            }
        }
        public IActionResult ShoppingCart()
        {
            List <OfferedLabourerService> serviceList = new List <OfferedLabourerService>();

            //Check if we're logged in.
            bool loggedIn = SessionController.returnLoggedIn(this.HttpContext);

            if (!loggedIn)
            {
                //Not logged in, get products from cookies
                List <string> keyList = Request.Cookies.Keys.Where(k => k.StartsWith("SC")).ToList();
                serviceList = Utility.CookieController.fetchItemsInCookies(keyList);
            }

            else
            {
                //Logged in, get products from database
                List <Object> offeredServiceIds = MollShopContext.GetShoppingCartItems((int)HttpContext.Session.GetInt32("UserId"));
                serviceList = new List <OfferedLabourerService>();

                foreach (Object id in offeredServiceIds)
                {
                    serviceList.Add(ElasticSearch.Queries.EsOLSQuery <object> .findByOfferedServiceId((int)id));
                }
            }


            PayPalConfig payPalConfig = PayPalService.getPayPalConfig();

            ViewBag.payPayConfig = payPalConfig;

            return(View(serviceList));
        }
        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 IActionResult Write(int LabourerID, string FirstName, string LastName, int Gender, string Address, string ZipCode, string PhoneNumber, string Email)
        {
            //Insert een Labourer in de database
            Labourer        lab     = new Labourer(LabourerID, FirstName, LastName, Gender, Address, ZipCode, PhoneNumber, Email);
            MollShopContext context = HttpContext.RequestServices.GetService(typeof(TestWebApp.Models.MollShopContext)) as MollShopContext;

            context.WriteLabourer(lab);
            return(RedirectToAction("Index", "Labourer"));
        }
        public static LoginModel Login(LoginModel loginMdl, HttpContext context)
        {
            loginMdl = MollShopContext.UserLogin(loginMdl);

            int result = loginMdl.UserId;

            if (result <= 0)
            {
                //Authentication unsuccessful
                switch (result)
                {
                case 0:
                    loginMdl.Message = "Wrong password!";
                    break;

                case -1:
                    loginMdl.Message = "Account has not been found!";
                    break;

                case -2:
                    loginMdl.Message = "Something went wrong on our end. Please contact support.";
                    break;

                case -3:
                    loginMdl.Message = "Hello, " + loginMdl.UserName + ". It seems you have not yet activated your account. Please check your mail!";
                    break;

                default:

                    break;
                }
            }

            else
            {
                //Authentication was successful
                context.Session.SetInt32("UserId", loginMdl.UserId);
                context.Session.SetString("User", loginMdl.EmailAddress);
                context.Session.SetString("UserName", loginMdl.UserName);
                context.Session.SetString("LoggedIn", "true");
                context.Session.SetString("Admin", loginMdl.Admin.ToString());

                //If the user has logged in, we need to check if they have any items added to their Shopping cart cookies, and add it to the database

                List <string> items = context.Request.Cookies.Keys.Where(s => s.StartsWith("SC")).ToList();

                foreach (string item in items)
                {
                    int fld_offeredserviceid = Convert.ToInt32(item.Substring(2));
                    AddtoShoppingCart(fld_offeredserviceid, loginMdl.UserId);
                }
            }

            return(loginMdl);
        }
        public IActionResult CreateOrders(string fld_email)
        {
            try
            {
                //Create the orders

                List <int> orderIds = ParseOrdersToList();
                Order      order    = new Order();

                order.fld_email = fld_email;
                if (fld_email == null)
                {
                    //The OrderMail Session Key is null. This means the user is already logged in, and did not need to save that key
                    order.fld_email = HttpContext.Session.GetString("User");
                }

                //Insert the Orders in the database
                foreach (int orderId in orderIds)
                {
                    order.fld_OfferedServiceId = orderId;
                    MollShopContext.CreateRow(order, "tbl_orders");

                    //If the user is logged in, we need to remove the orders from their database shopping cart
                    if (fld_email == null)
                    {
                        DatabaseController.RemoveFromShoppingCart(orderId, (int)HttpContext.Session.GetInt32("UserId"));
                    }
                }

                //With this, we have created the orders, and the user is now in the process of paying for their products. We can delete the orders.

                //First, we move the orders in the Session to a new Key. This way, we can still summarize the Orders if the order was successful later, but at the same time
                //We prevent the orders from being made multiple times over by user accident

                //Put the Ordered items in "PUR", for "Purchased
                this.HttpContext.Session.SetString("PUR", this.HttpContext.Session.GetString("ORD"));

                //Remove the orders from the Session
                this.HttpContext.Session.Remove("ORD");

                //Remove the ShoppingCart items from the Cookies
                List <string> items = HttpContext.Request.Cookies.Keys.Where(s => s.StartsWith("SC")).ToList();

                foreach (string item in items)
                {
                    Response.Cookies.Delete(item);
                }
            }

            catch (Exception e)
            {
            }

            return(View("Success"));
        }
        public int CreateItem(string insertedDic, string type)
        {
            //return the id back to the JS Datatable!
            switch (type)
            {
            case "tbl_userdata":
                tbl_userdata newUser = JsonConvert.DeserializeObject <tbl_userdata>(insertedDic);

                //Check if the email has been taken already
                int emailIsTaken = MollShopContext.CheckIfUserExists(newUser.fld_email);

                if (emailIsTaken == 0)
                {
                    //Email has not yet been taken

                    //Salt and Hash the password
                    newUser.fld_password = MollShopContext.SaltNHash(newUser.fld_password);

                    newUser.fld_userid = MollShopContext.CreateRow(newUser, type);

                    if (newUser.fld_dateofbirth == "")
                    {
                        newUser.fld_dateofbirth = null;
                    }
                    EsUpdater <tbl_userdata> .InsertDocument(newUser, "moll_users", "User", newUser.fld_userid.ToString());

                    return(newUser.fld_userid);
                }

                else
                {
                    //Email has been taken
                    return(-1);
                }

            case "tbl_servicedata":
                tbl_servicedata newService = JsonConvert.DeserializeObject <tbl_servicedata>(insertedDic);
                newService.fld_serviceid = MollShopContext.CreateRow(newService, type);
                EsUpdater <tbl_servicedata> .InsertDocument(newService, "moll_dataservices", "Services", newService.fld_serviceid.ToString());

                return(newService.fld_serviceid);

            case "tbl_labourerdata":
                tbl_labourerdata newLabourer = JsonConvert.DeserializeObject <tbl_labourerdata>(insertedDic);
                newLabourer.fld_labourerid = MollShopContext.CreateRow(newLabourer, type);
                EsUpdater <tbl_labourerdata> .InsertDocument(newLabourer, "moll_labourers", "Labourer", newLabourer.fld_labourerid.ToString());

                return(newLabourer.fld_labourerid);

            default:
                break;
            }

            return(0);
        }
Beispiel #10
0
        public IActionResult ChangeAccount(tbl_userdata user)
        {
            MollShopContext.UpdateRow(user, "fld_userid", (int)HttpContext.Session.GetInt32("UserId"));

            if (user.fld_username != null)
            {
                HttpContext.Session.SetString("UserName", user.fld_username);
            }

            return(RedirectToAction("MyAccount", "Account"));
        }
Beispiel #11
0
        public IActionResult AlterTextField(string field, string newText)
        {
            int userId = (int)HttpContext.Session.GetInt32("UserId");

            if (field == "fld_password")
            {
                newText = MollShopContext.SaltNHash(newText);
            }
            MollShopContext.UpdateVarCharField("tbl_userdata", field, newText.ToString(), "fld_UserId", userId);

            return(RedirectToAction("MyAccount", "Account"));
        }
        public IActionResult DoRegister(string UserName, string Password, string FirstName, string LastName, string GenderValue, string Adres, string ZipCode, string DOB, string Phone, string Email)
        {
            tbl_userdata user = new tbl_userdata();

            user.fld_username    = UserName;
            user.fld_password    = Password;
            user.fld_firstname   = FirstName;
            user.fld_lastname    = LastName;
            user.fld_gender      = GenderValue;
            user.fld_address     = Adres;
            user.fld_zipcode     = ZipCode;
            user.fld_dateofbirth = DOB;
            user.fld_phonenumber = Phone;
            user.fld_email       = Email;

            int emailIsTaken = MollShopContext.CheckIfUserExists(user.fld_email);

            if (emailIsTaken == 0)
            {
                int userNameExistance = MollShopContext.CheckIfUserNameIsTaken(user.fld_username);

                switch (userNameExistance)
                {
                case 0:
                    user.fld_adminPriv = "N";
                    string activationToken = MollShopContext.RegisterNewUser(user);
                    if (activationToken == "Db Error!")
                    {
                        ViewData["message"] = "Something went wrong on our end. Please contact support.";
                        break;
                    }
                    SendVerificationLink(activationToken, user.fld_email);
                    return(View("Login", new LoginModel()));

                case 1:
                    ViewData["message"] = "This user name is already in use!";
                    break;

                default:
                    ViewData["message"] = "Something went wrong on our end. Please contact support.";
                    break;
                }
                return(View("Register", user));
            }

            else
            {
                ViewData["message"] = "This email address has already been registered";
                return(View("Register", user));
            }
        }
Beispiel #13
0
        public IActionResult Register(string UserName, string Password, string FirstName, string LastName, string GenderValue, string Adres, string ZipCode, string DOB, string Phone, string Email)
        {
            User            user       = new User(UserName, Password, FirstName, LastName, GenderValue, Adres, ZipCode, DOB, Phone, Email);
            LoginModel      loginMdl   = new LoginModel(Email, Password);
            MollShopContext context    = HttpContext.RequestServices.GetService(typeof(TestWebApp.Models.MollShopContext)) as MollShopContext;
            int             userExists = context.CheckIfUserExists(loginMdl);

            if (userExists == 0)
            {
                context.RegisterNewUser(user);
                return(RedirectToAction("LI_index", "Page"));
            }
            return(View());
        }
Beispiel #14
0
        //Pagina voor My Account
        public IActionResult MyAccount()
        {
            //Vraag de useraccount op met een procedure
            //Get User ID from the browser session
            int?userId = HttpContext.Session.GetInt32("UserId");

            if (userId == null)
            {
                return(RedirectToAction("Login", "Page", new LoginModel()));
            }
            tbl_userdata foundUser = MollShopContext.FindUserById((int)userId);

            return(View(foundUser));
        }
        public async Task ConstructOrderVerificationMailAsync(string[] formVars)
        {
            //Get form information



            //Get labourer and service information
            List <OfferedLabourerService> purList = ParsePursToOls();

            Tuple <List <OfferedLabourerService>, string[]> emailModel = Tuple.Create(purList, formVars);

            string messageBody = await this.RenderViewAsync("OrderConfirmMail", emailModel);

            MollShopContext.SendEmail(formVars[4], "Order confirmation", messageBody);
        }
Beispiel #16
0
        public IActionResult Login(string Password, string EmailAddress)
        {
            LoginModel      loginMdl = new LoginModel(EmailAddress, Password);
            MollShopContext context  = HttpContext.RequestServices.GetService(typeof(TestWebApp.Models.MollShopContext)) as MollShopContext;
            int             result   = context.UserLogin(loginMdl);

            if (result == 1)
            {
                return(RedirectToAction("LI_index", "Page"));
            }

            else
            {
                return(View());
            }
        }
        //Requesting a password via email
        public IActionResult RequestPassword(string emailAddress)
        {
            string       subject = "Password request";
            tbl_userdata user    = MollShopContext.FindUserByEmail(emailAddress);

            if (user.fld_userid == null)
            {
                //wrong emailaddress, reload the page and add the message "Email account not found"
                //For now, redirect to homepage
                return(RedirectToAction("HomePage", "Page"));
            }

            string firstName = user.fld_firstname;

            string messageBody = "<p>Hi " + firstName + ", You requested your password via email, so here it is: " + user.fld_password + "</p>";

            MollShopContext.SendEmail(emailAddress, "Password request", messageBody);
            return(RedirectToAction("HomePage", "Page"));
        }
Beispiel #18
0
        public IActionResult VerifyAccount(string token, int userid)
        {
            tbl_userdata user = new tbl_userdata();

            user.fld_activationcode = token;
            user.fld_userid         = userid;
            int verificationResult = MollShopContext.VerifyUser(token, userid);

            switch (verificationResult)
            {
            case 1:
                ViewData["message"] = "Congratulations, your account is now verified!";

                break;

            default:
                ViewData["message"] = "omething went wrong. Please contact support";

                break;
            }
            return(View(user));
        }
        //This action does the authentication for registered users that are about to make a purchase
        public IActionResult DoAuthentication(string fld_emailaddress, string fld_password)
        {
            LoginModel loginMdl = new LoginModel(fld_emailaddress, fld_password);

            loginMdl = DatabaseController.Login(loginMdl, this.HttpContext);



            ViewBag.Message = loginMdl.Message;

            if (loginMdl.UserId <= 0)
            {
                return(View("PaymentAuthentication", this.HttpContext.Session.GetString("ORD")));
            }
            else
            {
                this.HttpContext.Session.SetString("OrderMail", loginMdl.EmailAddress);

                tbl_userdata user = MollShopContext.FindUserById(loginMdl.UserId);
                return(RedirectToAction("OrderSpecification", user));
            }
        }
        public IActionResult DeleteItem(int id, string type)
        {
            switch (type)
            {
            case "tbl_userdata":
                MollShopContext.DeleteRow(type, "fld_UserId", id);
                EsUpdater <tbl_userdata> .DeleteDocument(id, "User", "moll_users");

                break;

            case "tbl_servicedata":

                MollShopContext.DeleteRow(type, "fld_serviceid", id);
                EsUpdater <tbl_servicedata> .DeleteDocument(id, "Services", "moll_dataservices");

                break;

            case "tbl_labourerdata":
                MollShopContext.DeleteRow(type, "fld_labourerid", id);
                EsUpdater <tbl_labourerdata> .DeleteDocument(id, "Labourer", "moll_labourers");

                //Delete the OLS for this labourer as well

                break;

            case "offeredlabourerservice":
                MollShopContext.DeleteRow("tbl_offeredservicesdata", "fld_offeredServiceId", id);
                EsUpdater <OfferedLabourerService> .DeleteDocument(id, "OLS", "moll_ols");

                break;

            default:
                break;
            }

            return(Ok());
        }
        public OLS CreateOLS(string offeredService, string serviceId, string labourerId)
        {
            tbl_servicedata         service           = EsServiceQuery.FindById(Convert.ToInt32(serviceId));
            tbl_labourerdata        labourer          = EsLabourerQuery.FindById(Convert.ToInt32(labourerId));
            tbl_offeredservicesdata offeredServiceObj = JsonConvert.DeserializeObject <tbl_offeredservicesdata>(offeredService);

            offeredServiceObj.fld_labourerid = labourer.fld_labourerid;
            offeredServiceObj.fld_serviceid  = service.fld_serviceid;

            offeredServiceObj.fld_offeredserviceid = MollShopContext.CreateRow(offeredServiceObj, "tbl_offeredservicesdata");

            OLS ols = ConstructOLS(service, labourer, offeredServiceObj);

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

            EsUpdater <OLS> .InsertDocument(ols, "moll_ols", "OLS", ols.fld_offeredserviceid.ToString());

            //return the OfferedLabourerService, so we can later render it into the Datatable on the ManageOLS page
            //We must divide the cost by a 100 again, to render it correctly

            ols.fld_cost = ols.fld_cost / 100;
            return(ols);
        }
        public static string AddtoShoppingCart(int fld_offeredserviceid, int fld_userid)
        {
            //Check eerst of de service al in de shoppingcart zit
            //zet het voor nu ff op false
            bool foundService = MollShopContext.CheckShoppingCartItem(fld_offeredserviceid, fld_userid);

            if (!foundService)
            {
                //Service zit nog niet in de shoppingcart.
                ShoppingCartItem item = new ShoppingCartItem();
                item.fld_offeredServiceId = fld_offeredserviceid;
                item.fld_UserId           = fld_userid;
                try
                {
                    MollShopContext.CreateRow(item, "tbl_shoppingcart");
                }

                catch (Exception e)
                {
                }
            }

            return("hey");
        }
        public int EditItem(string insertedDic, string type)
        {
            switch (type)
            {
            case "tbl_userdata":
                try
                {
                    tbl_userdata currentUser = JsonConvert.DeserializeObject <tbl_userdata>(insertedDic);

                    //Dates and ElasticSearch do not mix very well, so we do a little check beforehand
                    if (currentUser.fld_dateofbirth == "")
                    {
                        currentUser.fld_dateofbirth = null;
                    }

                    EsUpdater <tbl_userdata> .UpsertDocument(currentUser, "moll_users", "User", currentUser.fld_userid);

                    MollShopContext.UpdateRow(currentUser, "fld_UserId", currentUser.fld_userid);
                }
                catch (Exception e)
                {
                    return(-1);
                }

                break;

            case "tbl_servicedata":
                tbl_servicedata currentService = JsonConvert.DeserializeObject <tbl_servicedata>(insertedDic);

                //Update the stand-alone service document
                EsUpdater <tbl_servicedata> .UpsertDocument(currentService, "moll_dataservices", "Services", currentService.fld_serviceid);

                //Find all OLS documents in ES that contain this service
                List <OfferedLabourerService> packages = EsOLSQuery <OfferedLabourerService> .getByService(currentService.fld_serviceid);

                //Foreach OLS ID, update it with the current service
                foreach (OfferedLabourerService package in packages)
                {
                    package.fld_name        = currentService.fld_name;
                    package.fld_category    = currentService.fld_category;
                    package.fld_description = currentService.fld_description;
                    package.fld_imagelink   = currentService.fld_imagelink;

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

                MollShopContext.UpdateRow(currentService, "fld_ServiceId", currentService.fld_serviceid);

                break;

            case "tbl_labourerdata":
                tbl_labourerdata currentLabourer = JsonConvert.DeserializeObject <tbl_labourerdata>(insertedDic);

                //Update the stand-alone labourer document
                EsUpdater <tbl_labourerdata> .UpsertDocument(currentLabourer, "moll_labourers", "Labourer", currentLabourer.fld_labourerid);

                //Find all OLS documents in ES that contain this labourer
                List <OfferedLabourerService> olspackages = EsOLSQuery <OfferedLabourerService> .getByLabourer(currentLabourer.fld_labourerid);

                //Foreach OLS Id, update it with the current labourer
                foreach (OfferedLabourerService package in olspackages)
                {
                    package.fld_address     = currentLabourer.fld_address;
                    package.fld_firstname   = currentLabourer.fld_firstname;
                    package.fld_email       = currentLabourer.fld_email;
                    package.fld_gender      = currentLabourer.fld_gender;
                    package.fld_lastname    = currentLabourer.fld_lastname;
                    package.fld_phonenumber = currentLabourer.fld_phonenumber;
                    package.fld_zipcode     = currentLabourer.fld_zipcode;

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

                MollShopContext.UpdateRow(currentLabourer, "fld_LabourerId", currentLabourer.fld_labourerid);

                break;

            default:
                break;
            }

            return(1);
        }
        public IActionResult Details(string labourerId)
        {
            tbl_labourerdata labourer = MollShopContext.FindLabourerById(labourerId);

            return(View("Details", labourer));
        }
        public async Task <IActionResult> Success()
        {
            //This action returns the result of the payment.
            //This is when the order will receive it's first update: it's either payed or encountered an error.
            var result = PDTHolder.Success(Request.Query["tx"].ToString());

            //Update the order status and history, update the offeredservice


            //Get previously entered order information
            string form      = HttpContext.Session.GetString("FORM");
            char   separator = ';';

            string[] formVars = form.Split(separator);

            //Send a confirmation email
            await ConstructOrderVerificationMailAsync(formVars);


            string     email             = formVars[4];
            List <int> offeredServiceIds = ParsePursToList();

            foreach (int olsId in offeredServiceIds)
            {
                //Fetch the order id
                int orderId = MollShopContext.FindOrderId(olsId, email);


                //Insert a new order history
                tbl_orderhistory history = new tbl_orderhistory();
                history.fld_ActionDate  = DateTime.Now;
                history.fld_lastAction  = "Paid order";
                history.fld_orderstatus = "Sent";
                history.fld_orderid     = orderId;

                MollShopContext.CreateRow(history, "tbl_orderhistory");

                //Insert a new order status
                tbl_orderstatus orderStatus = new tbl_orderstatus();
                orderStatus.fld_dateOrdered        = DateTime.Now;
                orderStatus.fld_orderid            = orderId;
                orderStatus.fld_targetDeliveryDate = DateTime.Now.AddDays(7);
                orderStatus.fld_DateUpdated        = DateTime.Now;
                MollShopContext.CreateRow(orderStatus);

                //Set the availability of the service to 'N'

                //ElasticSearch
                EsUpdater <OfferedLabourerService> .UpdateField("" + olsId, "fld_stillavailable", 'N');

                //Database
                tbl_offeredservicesdata os = new tbl_offeredservicesdata();
                os.fld_stillavailable = 'N';

                MollShopContext.UpdateRow(os, "fld_OfferedServiceId", olsId);
            }



            return(View("Success"));
        }