Exemplo n.º 1
0
        public ActionResult login(string User_Email, string Password)
        {
            User_table user = ul.login(User_Email, Password);

            if (user != null)
            {
                var base64 = Convert.ToBase64String(user.ProfilePicture);
                var ImgSRC = string.Format("data:image/gif;base64,{0}", base64);
                Session.Add("user", user);
                Session.Add("User_Id", user.User_Id);
                Session.Add("UserFullname", user.FName + " " + user.LName);
                Session.Add("User_Email", user.User_Email);
                Session.Add("ProfilePicture", ImgSRC);
                Session.Add("Rating", user.Rating);
                Session.Add("Bio", user.Bio);
                Session.Add("Gender", user.Gender);
                if (user.Type_id == 2)
                {
                    Session.Add("vendor", "vendor");
                }
                if (Session["checkOutRequest"] != null)
                {
                    return(RedirectToAction("cartDisplay", "Cart"));
                }
                else
                {
                    return(RedirectToAction("Home", "User"));
                }
            }
            else
            {
                ViewBag.NotValidUser = "******";
                return(View("login"));
            }
        }
Exemplo n.º 2
0
        public List <ProductModel> lastAdded()
        {
            User_table userSession = (User_table)HttpContext.Current.Session["user"];



            var query = (from p in context.Product_table
                         orderby p.Add_Date descending
                         select p).ToList();

            var x = (from p in query
                     join f in context.Following_table
                     on p.Vendor_id equals f.Vendor_id
                     where f.User_id == userSession.User_Id && p.State == "approved"
                     select new ProductModel
            {
                Product_Id = p.Product_Id,
                Product_Description = p.Product_Description,
                Product_Name = p.Product_Name,
                Image = p.Image,
                Product_Price = p.Product_Price,
                Vendor_id = p.Vendor_id
            }).ToList();

            return(x);
        }
Exemplo n.º 3
0
        public void AdminDescision(int id, string status)
        {
            Request_table req = new Request_table();

            req          = context.Request_table.Where(x => x.Request_Id == id).FirstOrDefault();
            req.reqState = status;
            int userid = req.User_Id;

            if (req.reqState.ToLower() == "approved")
            {
                User_table user = new User_table();
                user         = context.User_table.Where(x => x.User_Id == userid).FirstOrDefault();
                user.Type_id = 2;
            }

            Admin_Req_App_table AdminApprove = new Admin_Req_App_table();

            AdminApprove.Request_Id = id;
            AdminApprove.State      = status;

            Admin_table admin = (Admin_table)HttpContext.Current.Session["admin"];

            AdminApprove.Admin_Id = 1;
            //    return VendorRequest;

            context.Admin_Req_App_table.Add(AdminApprove);

            context.SaveChanges();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            User_table user_table = db.User_table.Find(id);

            db.User_table.Remove(user_table);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 5
0
        public ActionResult VendorRegister(string FullName, int NationalId, string Bio)
        {
            User_table USer = (User_table)Session["user"];

            int id = USer.User_Id;

            BL.User user = new BL.User();
            ViewBag.message = user.Vendor_Register(FullName, NationalId, Bio, id);
            return(PartialView());
        }
Exemplo n.º 6
0
        public int AddUser(User_table u)
        {
            var Pwd = u.UserPwd;

            var UserPwd = MD5Helper.MD5(Pwd);

            string sql = $"INSERT INTO User_table VALUES(NULL,'{u.UserPhone}', '{u.UserName}','{UserPwd}',{u.UserAge},'{u.UserID_card}','{u.User_Avatar}')";

            return(DLH_DBHelper.CMD(sql));
        }
 public ActionResult Edit([Bind(Include = "Id,user_name,user_email,user_password")] User_table user_table)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user_table).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user_table));
 }
        public ActionResult Create([Bind(Include = "Id,user_name,user_email,user_password")] User_table user_table)
        {
            if (ModelState.IsValid)
            {
                db.User_table.Add(user_table);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user_table));
        }
Exemplo n.º 9
0
        public List <User_table> myFollowedVendor(int ID)
        {
            List <User_table> FollwedUsers = new List <User_table>();
            List <int>        FollowedIds  = context.Following_table.Where(s => s.User_id == ID).Select(s => s.Vendor_id).ToList();

            for (int i = 0; i < FollowedIds.Count; i++)
            {
                int        followid    = FollowedIds[i];
                User_table FollwedUser = context.User_table.FirstOrDefault(s => s.User_Id == followid);
                FollwedUsers.Add(FollwedUser);
            }
            return(FollwedUsers);
        }
        // GET: User_table/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User_table user_table = db.User_table.Find(id);

            if (user_table == null)
            {
                return(HttpNotFound());
            }
            return(View(user_table));
        }
Exemplo n.º 11
0
 public ActionResult Login(User_table objUser)
 {
     if (ModelState.IsValid)
     {
         using (AuctionDBEntities db = new AuctionDBEntities()) {
             var obj = db.User_table.Where(a => a.user_name.Equals(objUser.user_name) && a.user_password.Equals(objUser.user_password)).FirstOrDefault();
             if (obj != null)
             {
                 Session["Id"]        = objUser.Id.ToString();
                 Session["user_name"] = objUser.user_name.ToString();
                 Session["isActive"]  = objUser.isActive.ToString();
                 return(RedirectToAction("Auction", "Home"));
             }
         }
     }
     return(View(objUser));
 }
Exemplo n.º 12
0
        //User Register (Sign Up)
        public bool Sign_Up_As_User(UserModel newUser)
        {
            bool Check;

            byte[] fileData     = null;
            var    binaryReader = new BinaryReader(newUser.ProfilePicture.InputStream);

            fileData = binaryReader.ReadBytes(newUser.ProfilePicture.ContentLength);

            var RegistUser = (from RegUser in context.User_table
                              where RegUser.User_Email.Equals(newUser.email)
                              select RegUser.User_Email
                              ).FirstOrDefault();


            if (RegistUser == null)
            {
                User_table user = new User_table();

                user.FName          = newUser.fname;
                user.LName          = newUser.lname;
                user.User_Name      = newUser.username;
                user.User_Email     = newUser.email;
                user.Password       = newUser.password;
                user.PhoneNumber    = newUser.phone;
                user.SSN            = newUser.ssn;
                user.Type_id        = 1;
                user.ProfilePicture = fileData;
                user.Gender         = newUser.gender;
                user.Bio            = newUser.Bio;
                user.Rating         = 0;

                context.User_table.Add(user);
                context.SaveChanges();
                Check = true;
            }

            else
            {
                Check = false;
            }

            return(Check);
        }
Exemplo n.º 13
0
        //Selected User
        public ActionResult SelectedUser(int id)
        {
            Session.Add("profileid", id);
            BL.User    user         = new BL.User();
            User_table selecteduser = user.GetSelectedUser(id);

            ViewBag.user_id = selecteduser.User_Id;
            Product product = new Product();

            ViewBag.VendorProducts            = product.GetProductsOfvendor(id);
            ViewBag.BestSellingVendorProducts = product.BestSellingForVendor(id);

            if (Session["user"] != null)
            {
                ViewBag.substate = vendorlogic.checkfollow((int)Session["User_Id"], id);
            }

            return(View(selecteduser));
        }
Exemplo n.º 14
0
        public List <ProductModel> topSellerSup()
        {
            User_table userSession = (User_table)HttpContext.Current.Session["user"];

            int[] query = (from o in context.OrderDetails_table
                           join p in context.Product_table
                           on o.Pro_Id equals p.Product_Id

                           group o.Quantity by p.Product_Id into g
                           orderby g.Sum() descending
                           select g.Key).ToArray(); // get the top 5 orders

            List <ProductModel> topSoldProducts = new List <ProductModel>();

            ProductModel[] topSold = new ProductModel[query.Length];
            for (int i = 0; i < query.Length; i++)
            {
                int pid = query[i];

                var x = (from p in context.Product_table
                         join s in context.Subscribtion_table
                         on p.Cat_id equals s.Cat_Id
                         where p.Product_Id == pid && s.User_Id == userSession.User_Id && p.State == "approved"
                         select new ProductModel
                {
                    Product_Id = p.Product_Id,
                    Product_Description = p.Product_Description,
                    Product_Name = p.Product_Name,
                    Image = p.Image,
                    Product_Price = p.Product_Price,
                    Vendor_id = p.Vendor_id
                }).ToList();

                topSoldProducts.AddRange((List <ProductModel>)x);
            }
            return(topSoldProducts);
        }
Exemplo n.º 15
0
        //Get User or Vendor Which is clicked on his profile

        public User_table GetSelectedUser(int id)
        {
            User_table SelectedUser = context.User_table.Where(x => x.User_Id == id).FirstOrDefault();

            return(SelectedUser);
        }
Exemplo n.º 16
0
        public User_table login(string User_Email, string Password)
        {
            User_table user = context.User_table.Where(s => s.User_Email.Equals(User_Email) && s.Password.Equals(Password)).FirstOrDefault();

            return(user);
        }
Exemplo n.º 17
0
 public IActionResult AddUser([FromForm] User_table u)
 {
     return(Ok(Ubll.AddUser(u)));
 }
Exemplo n.º 18
0
 public int AddUser(User_table u)
 {
     return(Udal.AddUser(u));
 }