Beispiel #1
0
        //
        // GET: /Store/Details/5

        public ActionResult Details(int id = 0)
        {
            Store store = db.Stores.Find(id);

            if (store == null)
            {
                return(HttpNotFound());
            }
            if (store.StatusId == Constant.STATUS_BANNED || store.StatusId == Constant.STATUS_INACTIVE)
            {
                ViewBag.Message = "Sorry, this store is not available.";
                return(View("Error"));
            }
            if (store.StatusId == Constant.STATUS_PENDING)
            {
                ViewBag.Message = "Sorry, this store is waiting arropve by admin";
                return(View("Error"));
            }
            if (User.Identity.IsAuthenticated != false)
            {
                UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);
                ViewBag.detailuser = user;
            }
            else
            {
                ViewBag.detailuser = null;
            }
            List <UserProfile> listprofile = new List <UserProfile>();

            listprofile         = Follow_Logic.GetFollowingUsersOfType(3, id, 5);
            ViewBag.listprofile = listprofile;
            return(View(store));
        }
Beispiel #2
0
        public ActionResult AddStoreFollow(int ID)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(Json("You must login to Follow", JsonRequestBehavior.AllowGet));
            }
            UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);
            Follow      temp = new Follow();

            temp.UserId  = user.UserId;
            temp.StoreId = ID;

            if (Follow_Logic.AddNewFollow(temp))
            {
                Store store = db.Stores.Find(ID);
                ++store.TotalFollowers;
                db.Entry(store).State = EntityState.Modified;
                db.SaveChanges();

                // Publish Message
                Message_Logic.PublishMessage(WebSecurity.CurrentUserId, Constant.PRONOUN_TYPE_USER, ID, Constant.PRONOUN_TYPE_STORE, Constant.MESSAGE_TYPE_FOLLOW);
                return(Json("true", JsonRequestBehavior.AllowGet));
            }
            return(Json("false", JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
 public ActionResult GetProductLike(int ID)
 {
     if (User.Identity.IsAuthenticated != false)
     {
         UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);
         return(Json(ProductLike_Logic.CheckLikeProductUserID(ID, user.UserId), JsonRequestBehavior.AllowGet));
     }
     return(Json(false, JsonRequestBehavior.AllowGet));
 }
Beispiel #4
0
 public ActionResult GetUserFollow(int ID)
 {
     if (User.Identity.IsAuthenticated != false)
     {
         UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);
         return(Json(Follow_Logic.CheckFollowForUser(user.UserId, ID, 2), JsonRequestBehavior.AllowGet));
     }
     return(Json(false, JsonRequestBehavior.AllowGet));
 }
Beispiel #5
0
        public ActionResult DeleteProductLike(int ID)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(Json("You must login to Like", JsonRequestBehavior.AllowGet));
            }
            UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);

            return(Json(ProductLike_Logic.DeleteProductLike(ID, user.UserId).ToString(), JsonRequestBehavior.AllowGet));
        }
 public ActionResult GetProductPage(int page)
 {
     if (User.Identity.IsAuthenticated)
     {
         UserProfile           user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);
         List <ProductDisplay> list = Product_Logic.GetListProductCateforyFollow(user.UserId, page, Constant.PAGE_SIZE);
         return(Json(list, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(null));
     }
 }
Beispiel #7
0
        public ActionResult AddProductLike(int ID)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(Json("You must login to Like", JsonRequestBehavior.AllowGet));
            }
            UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);

            if (ProductLike_Logic.AddProductLike(ID, user.UserId))
            {
                return(Json("true", JsonRequestBehavior.AllowGet));
            }
            return(Json("Error", JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        public ActionResult DeleteUserFollow(int ID)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(Json("You must login to Like", JsonRequestBehavior.AllowGet));
            }
            UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);

            if (Follow_Logic.DeletFollow(user.UserId, ID, 2))
            {
                return(Json("true", JsonRequestBehavior.AllowGet));
            }
            return(Json("false", JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        //
        // GET: /Product/Details/5

        public ActionResult Details(int id = 0)
        {
            Product product = db.Products.Find(id);

            if (product == null)
            {
                return(HttpNotFound());
            }
            Store store = product.Store;

            if (product.StatusId == Constant.STATUS_BANNED || product.StatusId == Constant.STATUS_INACTIVE || store.StatusId == Constant.STATUS_BANNED || store.StatusId == Constant.STATUS_INACTIVE)
            {
                ViewBag.Message = "Sorry, this product is not available.";
                return(View("Error"));
            }
            if (store.StatusId == Constant.STATUS_PENDING)
            {
                ViewBag.Message = "Sorry, The store of product is pending.";
                return(View("Error"));
            }
            if (User.Identity.IsAuthenticated != false)
            {
                UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);
                ViewBag.detailuser = user;
            }
            else
            {
                ViewBag.detailuser = null;
            }

            // List product recommend
            List <Product> listrecommend = Product_Logic.GetListProdcutRecommend(id, 4);

            ViewBag.listrecommend = listrecommend;
            // List user like product
            List <UserProfile> listlike = Product_Logic.GetListUserProfileRandom(1, id, 5, WebSecurity.IsAuthenticated ? WebSecurity.CurrentUserId : 0);

            ViewBag.listlike = listlike;
            // List user buy product
            List <UserProfile> listbuy = Product_Logic.GetListUserProfileRandom(2, id, 5, WebSecurity.IsAuthenticated ? WebSecurity.CurrentUserId : 0);

            ViewBag.listbuy = listbuy;
            // List comment product
            List <Comment> listcmt = Comment_Logic.GetListCommentByProductID(id);

            ViewBag.listcmt = listcmt;
            return(View(product));
        }
        public ActionResult Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);
                ViewBag.totalrow = Product_Logic.GetTotalRowListProductCateforyFollow(user.UserId);
                ViewBag.listpro  = Product_Logic.GetListProductCateforyFollow(user.UserId, 1, Constant.PAGE_SIZE);
            }
            else
            {
                ViewBag.totalrow = 0;
                ViewBag.listpro  = null;
            }
            ViewBag.EditorPicks = db.EditorPicks.ToList();
            var products = db.Products.OrderByDescending(p => p.CreateDate).ToList();

            return(View(products));
        }
Beispiel #11
0
        public ActionResult DeleteStoreFollow(int ID)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(Json("You must login to Follow", JsonRequestBehavior.AllowGet));
            }
            UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);

            if (Follow_Logic.DeletFollow(user.UserId, ID, 3))
            {
                Store store = db.Stores.Find(ID);
                --store.TotalFollowers;
                db.Entry(store).State = EntityState.Modified;
                db.SaveChanges();

                return(Json("true", JsonRequestBehavior.AllowGet));
            }
            return(Json("false", JsonRequestBehavior.AllowGet));
        }
Beispiel #12
0
        //
        // GET: /Profile/Edit/5

        public ActionResult Edit(int id = 0)
        {
            if (id < 0)
            {
                ViewBag.Message = "Sorry, profileid not found";
                return(View("Error"));
            }

            if (User.Identity.IsAuthenticated == false)
            {
                ViewBag.Message = "Sorry, you must login ";
                return(View("Error"));
            }
            UserProfile user = UserProfiles_Logic.GetUserProfileByUserName(User.Identity.Name);

            string [] roles = Roles.GetRolesForUser(User.Identity.Name);
            if (roles[0] == Constant.ROLE_ADMIN)
            {
                Profile profile = db.Profiles.Find(id);
                profile.DateOfBirth = profile.DateOfBirth.Date;
                if (profile == null)
                {
                    return(HttpNotFound());
                }
                return(View(profile));
            }
            else
            {
                if (user.ProfileId != id)
                {
                    ViewBag.Message = "Sorry, profileid not found";
                    return(View("Error"));
                }
                Profile profile = db.Profiles.Find(id);
                profile.DateOfBirth = profile.DateOfBirth.Date;
                if (profile == null)
                {
                    return(HttpNotFound());
                }
                return(View(profile));
            }
        }