public ActionResult Index(int id, EventCommentViewModel model)
 {
     CreateCommentModel ccm = new CreateCommentModel
     {
         Comment = model.NewComment,
         EventId = id,
         UserProfileId = AccountServices.GetInstance().GetUserByUsername(User.Identity.Name).UserProfile.UserProfileId
     };
     commentServices.CreateComment(ccm);
     return Index(id);
 }
        public ActionResult Index(int id = 0)
        {
            EventModel model = eventServices.GetEventById(id);
            if (model == null) return RedirectToAction("Index", "Home");

            IEnumerable<MediaItemModel> medias = MediaServices.GetInstance().GetMediaItemsByEvent(model.EventId);
            List<String> mediasFilesnames = new List<String>();

            foreach (MediaItemModel mim in medias)
            {
                //mediasFilesnames.Add(HttpContext.Server.MapPath("~/Uploads/Images/" + mim.FileName));
                mediasFilesnames.Add(mim.FileName);
            }

            EventCommentViewModel ecvm = new EventCommentViewModel
            {
                Address = model.Location.Address,
                Latitude = model.Location.Latitude,
                Longitude = model.Location.Longitude,
                EventId = model.EventId,
                StartTime = model.StartTime,
                EndTime = model.EndTime,
                Title = model.Title,
                Description = model.Description,
                Created = model.Created,
                CreatedById = model.CreatedById,
                IsActive = model.IsActive,
                IsPrivate = model.IsPrivate,
                LastModified = model.LastModified,
                Rating = model.Rating,
                NewComment = "",
                MediaFileNameList = mediasFilesnames.AsEnumerable(),
                CategoryString = model.Category.Name,
                CreatorUsername = accountServices.GetUserByUserProfileId(model.CreatedById).Username
            };

            ecvm.CreatedByUser = false;
            UserProfileModel profile = accountServices.GetUserProfileByUsername(User.Identity.Name);
            if (profile != null)
            {
                if (ecvm.CreatedById == profile.UserProfileId)
                {
                    ecvm.CreatedByUser = true;
                }
            }

            IEnumerable<CommentModel> tempie = commentServices.GetAllCommentsByEventId(model.EventId);
            List<CommentViewModel> commentList = new List<CommentViewModel>();

            DateTime now = DateTime.Now;

            int userProfileId = accountServices.GetUserByUsername(User.Identity.Name).UserProfile.UserProfileId;

            foreach (CommentModel cm in tempie)
            {
                UserProfileModel upm = accountServices.GetUserProfileByUserProfileId(cm.UserProfileId);

                CommentViewModel cvm = new CommentViewModel
                {
                    CommenterName = upm.FirstName + " " + upm.LastName,
                    CommentId = cm.CommentId,
                    CommentText = cm.CommentText,
                    EventId = cm.EventId,
                    Timestamp = cm.Timestamp,
                    UserProfileId = cm.UserProfileId,
                    UserIsAuthor = cm.UserProfileId == userProfileId
                };

                if (now.Month == cm.Timestamp.Month)
                {
                    if (now.Day == cm.Timestamp.Day)
                    {
                        int mins;
                        if (now.Hour == cm.Timestamp.Hour)
                        {
                            mins = (now.Minute - cm.Timestamp.Minute);
                        }
                        else if (now.Hour == cm.Timestamp.Hour + 1 && (now.Minute + 60 - cm.Timestamp.Minute) < 60)
                        {
                            mins = (now.Minute + 60 - cm.Timestamp.Minute);
                        }
                        else
                        {
                            mins = -1;
                        }

                        if (mins == 0)
                        {
                            cvm.TimeString = "Just now";
                        }
                        else if (mins == 1)
                        {
                            cvm.TimeString = "1 minute ago";
                        }
                        else if (mins == -1)
                        {
                            cvm.TimeString = cm.Timestamp.ToShortTimeString();
                        }
                        else
                        {
                            cvm.TimeString = mins + " minutes ago";
                        }

                    }
                    else
                    {
                        cvm.TimeString = cm.Timestamp.ToShortDateString();
                    }
                }
                else
                {
                    cvm.TimeString = cm.Timestamp.ToShortDateString();
                }

                commentList.Add(cvm);
            }

            ecvm.CommentList = commentList;

            return View(ecvm);
        }