Example #1
0
        public ActionResult Login(CUSTOMER customerModel)
        {
            var flag = 0;

            using (PSSCEntities dbModel = new PSSCEntities())
            {
                foreach (CUSTOMER cst in dbModel.CUSTOMERS)
                {
                    // if (dbModel.CUSTOMERS.Any(cst => cst.USERNAME == customerModel.USERNAME && cst.PASSWORD == customerModel.PASSWORD ))
                    if (cst.USERNAME == customerModel.USERNAME && cst.PASSWORD == customerModel.PASSWORD)
                    {
                        flag          = 1;
                        customerModel = cst;
                    }
                }

                if (flag == 1)
                {
                    ViewBag.LoggedMessage = "LOGGED IN";
                    return(RedirectToAction("Menu", "Main", customerModel));
                }
                else
                {
                    ViewBag.IncorrectMessage = "Incorrect user or password";
                    return(View("Login", customerModel));
                    //return Content("eroare");
                }
            }
        }
Example #2
0
        public ActionResult Register(CUSTOMER customerModel)
        {
            using (PSSCEntities dbModel = new PSSCEntities())
            {
                if (dbModel.CUSTOMERS.Any(cst => cst.USERNAME == customerModel.USERNAME))
                {
                    ViewBag.TakenMessage = "Username already taken!";
                    return(View("Register", customerModel));
                }

                dbModel.CUSTOMERS.Add(customerModel);
                dbModel.SaveChanges();
            }
            ModelState.Clear();
            ViewBag.SuccesMessage = "Registration Successful";
            return(View("Register", new CUSTOMER()));
        }
Example #3
0
        // GET: History
        public ActionResult Show(CUSTOMER customerModel)
        {
            var x    = "s";
            var IBAN = customerModel.IBAN;


            using (PSSCEntities dbModel = new PSSCEntities())
            {
                foreach (TRANSACTION trn in dbModel.TRANSACTIONS)
                {
                    if (trn.USERIBAN == customerModel.IBAN)
                    {
                        //ViewBag.Message = trn;
                        return(View(trn));
                    }
                }


                return(View("~/Views/History/Empty.cshtml"));
            }
        }
Example #4
0
        // GET: Trade
        public ActionResult Index(CUSTOMER customerModel, string withdraw, string deposit, string transfer, string amount, string iban)
        {
            TRANSACTION transactionModel = new TRANSACTION();

            using (PSSCEntities dbModel = new PSSCEntities())
            {
                if (!string.IsNullOrEmpty(withdraw))//// make a withdrawal
                {
                    if (Int32.Parse(customerModel.FIRSTNAME) < Int32.Parse(amount))
                    {
                        ViewBag.Message = "Not enough funds to perform this action!";
                        return(View());
                        //return RedirectToAction("Show", "History", customerModel);
                    }
                    else
                    {
                        customerModel.FIRSTNAME    = (Int32.Parse(customerModel.FIRSTNAME) - Int32.Parse(amount)).ToString();
                        transactionModel.FIRSTNAME = amount;
                        Random rnd = new Random();
                        transactionModel.ID       = "4567";
                        transactionModel.USERIBAN = iban;
                        transactionModel.USERNAME = customerModel.USERNAME + "1";
                        transactionModel.LASTNAME = customerModel.LASTNAME;
                        transactionModel.PASSWORD = "******";
                        transactionModel.CUSTOMER = customerModel;
                        customerModel.TRANSACTIONS.Add(transactionModel);
                        dbModel.SaveChanges();
                        //dbModel.TRANSACTIONS.Add(transactionModel);
                        dbModel.SaveChanges();
                        Receive rcv = new Receive("Your account was deducted with the amount of " + amount + "dollars");
                        return(RedirectToAction("Show", "History", customerModel));
                        //return View();
                    }
                }
                if (!string.IsNullOrEmpty(deposit))
                {
                    customerModel.FIRSTNAME    = (Int32.Parse(customerModel.FIRSTNAME) + Int32.Parse(amount)).ToString();
                    transactionModel.FIRSTNAME = amount;
                    Random rnd = new Random();
                    transactionModel.ID       = rnd.Next(9999).ToString();
                    transactionModel.USERIBAN = iban;
                    transactionModel.USERNAME = customerModel.USERNAME + "1";
                    transactionModel.LASTNAME = customerModel.LASTNAME;
                    transactionModel.PASSWORD = "******";
                    transactionModel.CUSTOMER = customerModel;
                    customerModel.TRANSACTIONS.Add(transactionModel);
                    dbModel.SaveChanges();
                    //dbModel.TRANSACTIONS.Add(transactionModel);
                    dbModel.SaveChanges();
                    return(RedirectToAction("Show", "History", customerModel));
                    //return View();
                }
                if (!string.IsNullOrEmpty(transfer))
                {
                    foreach (CUSTOMER cst in dbModel.CUSTOMERS)
                    {
                        if (cst.IBAN.CompareTo(iban) == 0)
                        {
                            if (Int32.Parse(customerModel.FIRSTNAME) < Int32.Parse(amount))
                            {
                                ViewBag.Message = "Not enough funds to perform this action!";
                                return(View());
                                //return RedirectToAction("Show", "History", customerModel);
                            }
                            else
                            {
                                customerModel.FIRSTNAME    = (Int32.Parse(customerModel.FIRSTNAME) - Int32.Parse(amount)).ToString();
                                cst.FIRSTNAME              = (Int32.Parse(customerModel.FIRSTNAME) + Int32.Parse(amount)).ToString();
                                transactionModel.FIRSTNAME = amount;
                                Random rnd = new Random();
                                transactionModel.ID       = rnd.Next(9999).ToString();
                                transactionModel.USERIBAN = iban;
                                transactionModel.USERNAME = customerModel.USERNAME + "1";
                                transactionModel.LASTNAME = customerModel.LASTNAME;
                                transactionModel.PASSWORD = "******";
                                transactionModel.CUSTOMER = customerModel;
                                customerModel.TRANSACTIONS.Add(transactionModel);
                                dbModel.SaveChanges();
                                //dbModel.TRANSACTIONS.Add(transactionModel);
                                dbModel.SaveChanges();
                                Receive rcv = new Receive("Transfer successful. Your account was deducted with the amount of " + amount + "dollars");
                                return(RedirectToAction("Show", "History", customerModel));
                                //return View();
                            }
                        }
                    }
                    ViewBag.Message = "This iban doesn't exist in our database!";

                    return(View());
                }
            }
            return(View());
        }