Exemple #1
0
        //
        // GET: /Profile/Details/5

        public ActionResult Details(int id = 0)
        {
            UserProfile user = db.UserProfiles.Find(id);

            if (user == null)
            {
                ViewBag.Message = "User not found.";
                return(View("Error"));
            }
            Profile profile = user.Profile;

            if (profile == null)
            {
                return(HttpNotFound());
            }
            // Get List Follow
            List <UserProfile> listfollow = Follow_Logic.GetFollowingUsersOfType(2, id, 5);

            ViewBag.listfollow = listfollow;

            ViewBag._user = user;
            // Get list store follow
            List <Store> liststore = Account_Logic.GetListStoreFollowByUser(id);

            ViewBag.liststore = liststore;

            // Get list product like
            List <Product> listpro = Account_Logic.GetListProductLikeByUser(id);

            ViewBag.listpro = listpro;
            return(View(profile));
        }
Exemple #2
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));
        }
Exemple #3
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));
        }
Exemple #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));
 }
Exemple #5
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));
        }
Exemple #6
0
        public ActionResult AddUserFollow(int ID)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                return(Json("You must login to Like", JsonRequestBehavior.AllowGet));
            }
            Follow temp = new Follow();

            temp.UserId         = WebSecurity.CurrentUserId;
            temp.FollowedUserId = ID;
            if (Follow_Logic.AddNewFollow(temp))
            {
                // Publish Message
                Message_Logic.PublishMessage(WebSecurity.CurrentUserId, Constant.PRONOUN_TYPE_USER, ID, Constant.PRONOUN_TYPE_USER, Constant.MESSAGE_TYPE_FOLLOW);
                return(Json("true", JsonRequestBehavior.AllowGet));
            }
            return(Json("false", JsonRequestBehavior.AllowGet));
        }
Exemple #7
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));
        }