//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());
            }
        }
        //This action gets called when the user decides to not use an account when making their purchase
        public IActionResult UnregisteredAuthentication(string fld_emailaddress)
        {
            this.HttpContext.Session.SetString("OrderMail", fld_emailaddress);

            tbl_userdata user = new tbl_userdata();

            user.fld_email = fld_emailaddress;
            return(RedirectToAction("Orderspecification", user));
        }
        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);
        }
Esempio n. 4
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"));
        }
        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));
            }
        }
Esempio n. 6
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 IActionResult OrderSpecification(tbl_userdata user)
        {
            //This view will show the order the user is about to make
            //They can make last minute changes: for example: a different mailing address, a target send date, etc
            //By clicking the proceed button, the user will be directed to the PaymentMethod view

            //List all the services

            List <OfferedLabourerService> olsList = ParseOrdersToOLS();

            Tuple <List <OfferedLabourerService>, tbl_userdata> tuple = Tuple.Create(olsList, user);

            return(View(tuple));
        }
Esempio n. 8
0
        public ActionResult Login(tbl_userdata model)
        {
            using (var data = new MyDatabaseEntities())
            {
                bool isvalid = data.tbl_userdata.Any(x => x.Email == model.Email && x.Password == model.Password);
                if (isvalid)
                {
                    FormsAuthentication.SetAuthCookie(model.Username, false);
                    TempData["loginModel1"] = model;
                    return(RedirectToAction("List"));
                }

                else
                {
                    ModelState.AddModelError("", "Invalid email or Password.");
                    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"));
        }
Esempio n. 10
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));
            }
        }
Esempio n. 12
0
        public ActionResult Register(HttpPostedFileBase uploadfile, tbl_userdata obj)
        {
            String filename  = Path.GetFileName(uploadfile.FileName);
            String filename1 = DateTime.Now.ToString("yymmssfff") + filename;
            string extension = Path.GetExtension(uploadfile.FileName);

            String path = Path.Combine(Server.MapPath("/Images/"), filename1);

            obj.Profile = "/Images/" + filename1;

            if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
            {
                if (uploadfile.ContentLength <= 10000000)
                {
                    dbobj.tbl_userdata.Add(obj);
                    if (dbobj.SaveChanges() > 0)
                    {
                        uploadfile.SaveAs(path);
                        ModelState.AddModelError("", "Inserted Successfully.");
                        ModelState.Clear();

                        RedirectToAction("Login");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Upload Image file in proper size.");
                    RedirectToAction("Register");
                }
            }
            else
            {
                ModelState.AddModelError("", "Upload image in jpg, jpeg or png format.");
                RedirectToAction("Register");
            }
            return(View());
        }
        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 Register(tbl_userdata user)
 {
     return(View(user));
 }