Пример #1
0
        public IActionResult MatchDetail(int reviewid, string fromid)
        {
            ProfileReview         profile  = new ProfileReview();
            ProfileDetails        pdetail  = new ProfileDetails();
            List <ProfileComment> comments = new List <ProfileComment>();
            bool   iProposed = false;
            string profileId = "";

            var hasMatch = db.ProfileReview.Where(x => x.ProfileReviewId == reviewid);

            if (hasMatch.Any())
            {
                profile   = hasMatch.FirstOrDefault();
                profileId = profile.ProposedFromUserId == fromid ? profile.ProposedToUserId : profile.ProposedFromUserId;
                iProposed = profile.ProposedFromUserId == fromid ? true : false;
                pdetail   = db.ProfileDetails.Where(x => x.ProfileUserId == profileId).FirstOrDefault();
                comments  = db.ProfileComment.Where(x => x.ProfileReviewId == reviewid).OrderByDescending(x => x.CommentDate).ToList();
            }

            ViewBag.profile   = profile;
            ViewBag.iProposed = iProposed;
            ViewBag.comments  = comments;
            ViewBag.fromid    = fromid;
            ViewBag.toid      = profileId;
            return(View(pdetail));
        }
Пример #2
0
        public async Task <List <ProfileReview> > GetEventReviews(Guid accountId, string languageCode)
        {
            var identityUser = await this.userManager.FindByIdAsync(accountId.ToString());

            if (identityUser == null)
            {
                return(null);
            }

            var customer = this.context.Customers.FirstOrDefault(x => x.IdentityId == accountId.ToString());

            var customerEvents = new List <Event>();

            if (customer.CustomerType == CustomerType.Musician)
            {//get events by musician Id
                customerEvents = this.context.Events
                                 .Include(x => x.Reviews)
                                 .ThenInclude(y => y.EventReviewPhoto)
                                 .Include(x => x.Reviews)
                                 .ThenInclude(y => y.Reviewer)
                                 .Where(x => x.MusicianId == customer.Id)
                                 .ToList();
            }

            if (customer.CustomerType == CustomerType.EventManager)
            {//get events by event manager
                customerEvents = this.context.Events
                                 .Include(x => x.Reviews)
                                 .ThenInclude(y => y.EventReviewPhoto)
                                 .Include(x => x.Reviews)
                                 .ThenInclude(y => y.Reviewer)
                                 .Where(x => x.EventManagerId == customer.Id)
                                 .ToList();
            }

            var eventReviews = new List <ProfileReview>();

            foreach (var item in customerEvents)
            {
                var reviews = item.Reviews;

                var creator = this.context.Customers.FirstOrDefault(x => x.Id == customer.Id);

                if (creator == null)
                {
                    continue;
                }

                foreach (var review in reviews)
                {
                    var profileReview = new ProfileReview();

                    if (review.EventReviewPhoto != null)
                    {
                        var photoReviewPath = $"C:/TurnItUp/EventReviewPhotos/{item.Id}/{review.EventReviewPhoto.Id}/{review.EventReviewPhoto.Name}.{review.EventReviewPhoto.Extension}";
                        var reviewPhotoFile = new List <byte>();

                        if (File.Exists(photoReviewPath))
                        {
                            reviewPhotoFile = File.ReadAllBytes(photoReviewPath).ToList();
                            var photoBytes  = reviewPhotoFile.ToArray();
                            var photoBase64 = Convert.ToBase64String(photoBytes);

                            profileReview.EventReviewPhoto = new Dto.Photo
                            {
                                Name      = review.EventReviewPhoto.Name,
                                Extension = review.EventReviewPhoto.Extension,
                                Content   = photoBase64
                            };
                        }
                    }

                    profileReview.Date      = review.ReviewDate;
                    profileReview.Text      = review.Text;
                    profileReview.Rating    = review.Rating;
                    profileReview.EventLink = new Dto.Links.EventLink
                    {
                        EventId   = item.Id,
                        EventName = item.Name
                    };
                    profileReview.UserLink = new Dto.Links.AccountLink
                    {
                        UserId   = creator.Id,
                        UserName = creator.ProfileName
                    };

                    eventReviews.Add(profileReview);
                }
            }

            return(eventReviews);
        }
Пример #3
0
        public KeyValuePair <bool, string> SetMatch(SaiMatrimonyDb db, string proposedFromUserId, string proposedToUserId, string actionType, int reviewId)
        {
            ProfileReview  profileReview = new ProfileReview();
            ProfileDetails fromUser      = db.ProfileDetails.Where(x => x.ProfileUserId == proposedFromUserId).FirstOrDefault();
            ProfileDetails toIdUser      = db.ProfileDetails.Where(x => x.ProfileUserId == proposedToUserId).FirstOrDefault();
            ProfileComment comment       = new ProfileComment();
            CommonFunction common        = new CommonFunction();
            string         commentText   = string.Empty;
            string         msg           = "";
            bool           result        = false;

            try
            {
                if (actionType == "makeproposal")
                {
                    profileReview.ProposedFromUserId    = proposedFromUserId;
                    profileReview.ProposedToUserId      = proposedToUserId;
                    profileReview.HasMadeProposal       = true;
                    profileReview.DateMadeProposal      = DateTime.UtcNow;
                    profileReview.HasAcceptedDiscussion = false;
                    profileReview.HasAcceptedProposal   = false;
                    profileReview.HasRejectedProposal   = false;

                    db.ProfileReview.Add(profileReview);
                    db.SaveChanges();

                    comment = new ProfileComment();
                    comment.ProfileReviewId   = profileReview.ProfileReviewId;
                    comment.CommentText       = common.GetName(fromUser) + " proposed to " + common.GetName(toIdUser);
                    comment.CommentByUserName = common.GetName(fromUser);
                    comment.CommentByUserId   = fromUser.ProfileUserId;
                    comment.CommentDate       = DateTime.UtcNow;
                    db.ProfileComment.Add(comment);

                    db.SaveChanges();
                    return(new KeyValuePair <bool, string>(true, "Proposal has been made, You will be notified once the Match accepts discussion or your proposal"));
                }

                var hasprofile = db.ProfileReview.Where(x => x.ProfileReviewId == reviewId);
                if (hasprofile.Any())
                {
                    profileReview = hasprofile.FirstOrDefault();
                }
                else
                {
                    return(new KeyValuePair <bool, string>(false, "System could not match the profile, Contact Support for details"));
                }

                if (actionType == "acceptdiscussion" & profileReview.HasMadeProposal)
                {
                    profileReview.HasAcceptedDiscussion  = true;
                    profileReview.DateAcceptedDiscussion = DateTime.UtcNow;
                    db.SaveChanges();
                    commentText = common.GetName(fromUser) + " accepted to discuss " + common.GetName(toIdUser);
                    result      = true;
                    msg         = "You have accepted to dicuss with the match";
                    //return new KeyValuePair<bool, string>(true, "You have accepted to dicuss with the match");
                }
                else if (actionType == "acceptproposal" & profileReview.HasMadeProposal)
                {
                    profileReview.HasAcceptedProposal  = true;
                    profileReview.DateAcceptedProposal = DateTime.UtcNow;
                    db.SaveChanges();
                    commentText = common.GetName(fromUser) + " accepted proposal " + common.GetName(toIdUser);
                    result      = true;
                    msg         = "You have accepted the proposal with the match";
                    //return new KeyValuePair<bool, string>(true, "Match has been accepted. You will no longer have access to other profiles");
                }
                else if (actionType == "rejectproposal" & profileReview.HasMadeProposal)
                {
                    profileReview.HasRejectedProposal  = true;
                    profileReview.DateRejectedProposal = DateTime.UtcNow;
                    db.SaveChanges();
                    commentText = common.GetName(fromUser) + " rejected proposal " + common.GetName(toIdUser);
                    result      = true;
                    msg         = "You have rejected the proposal with the match";
                    //return new KeyValuePair<bool, string>(true, "Match has not been accepted. You will no longer have access to this profile");
                }

                comment = new ProfileComment();
                comment.ProfileReviewId   = reviewId;
                comment.CommentText       = commentText;
                comment.CommentByUserName = common.GetName(fromUser);
                comment.CommentByUserId   = fromUser.ProfileUserId;
                comment.CommentDate       = DateTime.UtcNow;
                db.ProfileComment.Add(comment);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                string ex = e.Message;
                return(new KeyValuePair <bool, string>(false, "System could not match the profile, Contact Support for details"));
            }

            if (result)
            {
                return(new KeyValuePair <bool, string>(result, msg));
            }

            return(new KeyValuePair <bool, string>(false, "System could not match the profile, Contact Support for details"));
        }