Beispiel #1
0
        public ActionResult EditEvent(ViewDetailEventModel model)
        {
            EditViewModel editModel = new EditViewModel();

            if (model.eventDescription.IsNullOrWhiteSpace())
            {
                editModel.Description = "";
            }
            else
            {
                editModel.Description = model.eventDescription;
            }
            editModel.EndTime   = model.EndTime;
            editModel.Privacy   = model.Privacy;
            editModel.StartTime = model.StartTime;
            editModel.Title     = model.eventName;
            editModel.eventID   = model.eventId;
            editModel.Location  = model.eventLocation;
            return(PartialView(editModel));
        }
Beispiel #2
0
        /// <summary>
        /// View detail of event
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(long?id)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user == null)
            {
                if (Request.Cookies["userName"] != null && Request.Cookies["password"] != null)
                {
                    string userName = Request.Cookies["userName"].Value;
                    string password = Request.Cookies["password"].Value;
                    if (UserDatabaseHelper.Instance.ValidateUser(userName, password))
                    {
                        user = UserDatabaseHelper.Instance.GetUserByUserName(userName);
                        if (UserDatabaseHelper.Instance.isLookedUser(user.UserName))
                        {
                            TempData["errorTitle"]   = "Locked User";
                            TempData["errorMessage"] = "Your account is locked! Please contact with our support";

                            return(RedirectToAction("Index", "Home"));
                        }
                        UserHelpers.SetCurrentUser(Session, user);
                    }
                }
            }

            if (id == null)
            {
                TempData["errorTitle"]   = "Failed to load event";
                TempData["errorMessage"] = "Event not avaiable!";
                return(RedirectToAction("Index", "Home"));
            }
            Event evt = EventDatabaseHelper.Instance.GetEventByID(id);

            if (evt == null)
            {
                TempData["errorTitle"]   = "Failed to load event";
                TempData["errorMessage"] = "Event not avaiable!";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (evt.Privacy == EventZoneConstants.privateEvent || evt.Status == EventZoneConstants.Lock)
                {
                    if (user != null && (EventDatabaseHelper.Instance.IsEventOwnedByUser(id, user.UserID) || user.UserRoles == EventZoneConstants.Mod))
                    {
                    }
                    else
                    {
                        TempData["errorTitle"]   = "Failed to load event";
                        TempData["errorMessage"] = "This event is set to private or has been locked!";
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            ViewDetailEventModel viewDetail = new ViewDetailEventModel();

            viewDetail.createdBy = EventDatabaseHelper.Instance.GetAuthorEvent(evt.EventID);
            viewDetail.eventId   = evt.EventID;
            viewDetail.eventName = evt.EventName;

            viewDetail.eventAvatar      = EventDatabaseHelper.Instance.GetImageByID(evt.Avatar).ImageLink;
            viewDetail.numberView       = evt.View;
            viewDetail.isVerified       = evt.IsVerified;
            viewDetail.eventDescription = evt.EventDescription;
            viewDetail.StartTime        = evt.EventStartDate;
            viewDetail.EndTime          = evt.EventEndDate;
            viewDetail.isOwningEvent    = false;
            viewDetail.NumberLike       = EventDatabaseHelper.Instance.CountLike(evt.EventID);
            viewDetail.NumberDisLike    = EventDatabaseHelper.Instance.CountDisLike(evt.EventID);
            viewDetail.NumberFowllower  = EventDatabaseHelper.Instance.CountFollowerOfEvent(evt.EventID);
            viewDetail.eventLocation    = EventDatabaseHelper.Instance.GetEventLocation(evt.EventID);
            viewDetail.eventVideo       = EventDatabaseHelper.Instance.GetEventVideo(evt.EventID);
            viewDetail.eventComment     = EventDatabaseHelper.Instance.GetListComment(evt.EventID);
            viewDetail.Category         = EventDatabaseHelper.Instance.GetEventCategory(evt.EventID);
            viewDetail.FindLike         = new LikeDislike();
            viewDetail.FindLike.Type    = EventZoneConstants.NotRate;
            viewDetail.FindLike.EventID = evt.EventID;
            LiveStreamingModel liveModel = new LiveStreamingModel {
                eventID = evt.EventID, Title = evt.EventName
            };

            TempData["LiveModel"] = liveModel;
            if (user != null)
            {
                viewDetail.isOwningEvent = EventDatabaseHelper.Instance.IsEventOwnedByUser(evt.EventID, user.UserID);
                if (viewDetail.isOwningEvent)
                {
                    viewDetail.eventImage = EventDatabaseHelper.Instance.GetEventImage(evt.EventID);
                }
                else
                {
                    viewDetail.eventImage = EventDatabaseHelper.Instance.GetEventApprovedImage(evt.EventID);
                }
                viewDetail.FindLike = UserDatabaseHelper.Instance.FindLike(user.UserID, evt.EventID);
                if (viewDetail.FindLike == null)
                {
                    viewDetail.FindLike      = new LikeDislike();
                    viewDetail.FindLike.Type = EventZoneConstants.NotRate;
                }
                viewDetail.isFollowing = UserDatabaseHelper.Instance.IsFollowingEvent(user.UserID, evt.EventID);
            }
            else
            {
                viewDetail.eventImage = EventDatabaseHelper.Instance.GetEventApprovedImage(evt.EventID);
            }
            viewDetail.Privacy = evt.Privacy;
            if (TempData["EventDetailTask"] == null)
            {
                ViewData["EventDetailTask"] = "EventDetail";
                if (user == null || EventDatabaseHelper.Instance.GetAuthorEvent(evt.EventID).UserID != user.UserID)
                {
                    EventDatabaseHelper.Instance.AddViewEvent(evt.EventID);
                    viewDetail.numberView = evt.View;
                }
                return(View(viewDetail));
            }
            else
            {
                ViewData["EventDetailTask"] = "EditEvent";
                return(View(viewDetail));
            }
        }