Пример #1
0
        public ActionResult MakeOrder(RegistrationVM model)
        {
            string productsId = Session["OrderProduct"].ToString();
            string quantities = Session["ProductQuantity"].ToString();
            string userID     = Session["User_ID"].ToString();

            string[] keyProduct  = productsId.Split(',');
            string[] keyQuantity = quantities.Split(',');

            User        user  = new User();
            UserServise _user = new UserServise();

            if (userID != null)
            {
                EncriptServises _encript = new EncriptServises();
                for (int i = 0; i < keyProduct.Length - 1; i++)
                {
                    Order entity = new Order();
                    entity.SubjectID   = int.Parse(keyProduct[i]);
                    entity.Quantity    = int.Parse(keyQuantity[i]);
                    entity.OrderNumber = Session["OrderNumber"].ToString();
                    entity.Date        = DateTime.Today.ToString("dd/MM/yyyy");
                    entity.Status      = Status.Supplier;

                    Product element = _product.GetByID(entity.SubjectID);
                    entity.Total = (entity.Quantity * element.Price);
                    _order.Save(entity);
                    entity.UserID = int.Parse(userID);
                    _order.Save(entity);


                    ChangewquantityOfPRoduct(element, entity.Quantity);
                }
            }
            else
            {
                user = AddUserInDB(user, model);
                _user.Save(user);
                user = new User();
                for (int i = 0; i < keyProduct.Length - 1; i++)
                {
                    Order entity = new Order();
                    entity.SubjectID   = int.Parse(keyProduct[i]);
                    entity.Quantity    = int.Parse(keyQuantity[i]);
                    entity.OrderNumber = Session["OrderNumber"].ToString();
                    entity.Date        = DateTime.Today.ToString("dd/MM/yyyy");
                    entity.Status      = Status.Supplier;
                    user          = _user.GetLastElement();
                    entity.UserID = user.ID;

                    Product element = _product.GetByID(entity.SubjectID);

                    entity.Total = (entity.Quantity * element.Price);
                    _order.Save(entity);
                    ChangewquantityOfPRoduct(element, entity.Quantity);
                }
            }
            DeleteSession();
            return(RedirectToAction("CungratOrder"));
        }
Пример #2
0
        private User PopulateUser(Order order)
        {
            User            entity   = new User();
            UserServise     _user    = new UserServise();
            EncriptServises _encript = new EncriptServises();
            var             model    = _user.GetByID(order.UserID);

            entity.Name       = _encript.DencryptData(model.Name);
            entity.SecondName = _encript.DencryptData(model.SecondName);
            entity.City       = _encript.DencryptData(model.City);
            entity.Adress     = _encript.DencryptData(model.Adress);
            entity.Telephone  = _encript.DencryptData(model.Telephone);

            return(entity);
        }
Пример #3
0
        private User AddUSerINformation(RegistrationVM reg)
        {
            List <Login> list = new List <Login>();

            list = _servise.GetAll(x => x.Email == _encript.EncryptData(reg.Email));
            User user = new User();

            user.LoginID    = list[0].ID;
            user.Name       = _encript.EncryptData(reg.FirstName);
            user.SecondName = _encript.EncryptData(reg.SecondName);
            user.City       = _encript.EncryptData(reg.City);
            user.Adress     = _encript.EncryptData(reg.Adress);
            user.Telephone  = _encript.EncryptData(reg.Telephone);
            user.Image      = "../images/userIcon.png";
            UserServise _userServise = new UserServise();

            _userServise.Save(user);
            return(user);
        }
Пример #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserServise us = new UserServise();

            foreach (GridViewRow row in GridView1.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chkRow = (row.Cells[4].FindControl("CheckBox1") as CheckBox);
                    if (chkRow.Checked)
                    {
                        string storid   = row.Cells[1].Text;
                        int    storname = Int32.Parse(row.Cells[2].Text);
                        string state    = row.Cells[3].Text;
                        //data = data + storid + " ,  " + storname + " , " + state + "<br>";
                        us.setType(storname);
                    }
                }
            }
            PopulateGrid();
            // lblmsg.Text = data;
        }
Пример #5
0
        public ActionResult MakeOrder()
        {
            RegistrationVM model  = new RegistrationVM();
            string         userID = Session["User_ID"].ToString();

            if (userID != null)
            {
                UserServise     _login   = new UserServise();
                EncriptServises _encript = new EncriptServises();
                User            user     = new User();
                user                    = _login.GetByID(int.Parse(userID));
                model.FirstName         = _encript.DencryptData(user.Name);
                model.SecondName        = _encript.DencryptData(user.SecondName);
                model.City              = _encript.DencryptData(user.City);
                model.Adress            = _encript.DencryptData(user.Adress);
                model.Telephone         = _encript.DencryptData(user.Telephone);
                ViewData["Information"] = "Вие имате регистрация в нашия  сайт! Моля натиснете бътона 'Поръчай', за да направите поръчката си!";
            }
            else
            {
                ViewData["Information"] = "Моля въведете информацията която се изисква за да направите вашата поръчка!";
            }
            return(View(model));
        }
Пример #6
0
        protected void btSignup_Click(object sender, EventArgs e)
        {
            bool        flag = true;
            UserServise us   = new UserServise();

            if (Validation.isEmpty(first_name.Text))
            {
                lFirstName.Text    = "Enter first name";
                lFirstName.Visible = true;
                flag = false;
            }
            else
            {
                lFirstName.Visible = false;
            }
            if (last_name.Text.Length == 0)
            {
                lLastName.Text    = "Enter last name";
                lLastName.Visible = true;
                flag = false;
            }
            else
            {
                lLastName.Visible = false;
            }
            if (email.Text.Trim().Length == 0)
            {
                lemail.Text    = "Enter email";
                lemail.Visible = true;
                flag           = false;
            }
            else if (!Validation.Email(email.Text))
            {
                lemail.Text    = "Invalid email address";
                lemail.Visible = true;
                flag           = false;
            }
            else
            {
                lemail.Visible = false;
            }
            if (user_name.Text.Trim().Length == 0)
            {
                lUserName.Text    = "Enter username";
                lUserName.Visible = true;
                flag = false;
            }

            else if (us.CheckUsername(user_name.Text) != 0)
            {
                flag              = false;
                lUserName.Text    = "Username already exists";
                lUserName.Visible = true;
            }
            else
            {
                lUserName.Visible = false;
            }
            if (password.Text.Trim().Length < 6)
            {
                flag              = false;
                lPassword.Text    = "Password must contain at least 6 characters";
                lPassword.Visible = true;
            }
            else
            {
                if (password.Text != password_confirmation.Text)
                {
                    flag = false;
                    lpassword_confirmation.Text    = "Please check that you've entered and confirmed your password";
                    lpassword_confirmation.Visible = true;
                }
                else
                {
                    lpassword_confirmation.Visible = false;
                }
                lPassword.Visible = false;
            }
            if (!t_and_c.Checked)
            {
                flag             = false;
                lt_and_c.Text    = "you must agree to our terms of service and privacy policy";
                lt_and_c.Visible = true;
            }
            else
            {
                lt_and_c.Visible = false;
            }
            if (flag)
            {
                Users u = new Users(Request.Form["first_name"], last_name.Text.Trim(), email.Text.Trim(), user_name.Text.Trim(), password.Text.Trim());
                us.InsertUser(u);
                Session["user"] = u;
                Response.Redirect("~/LogIn.aspx");
            }
        }
Пример #7
0
 public UserController(UserServise userService)
 {
     _userServices = userService;
 }