Ejemplo n.º 1
0
        public override void Handle(Report report, RepoFacade repo)
        {
            Ad   ad    = repo.GetAd(report.AdCategory, report.AdId);
            User owner = repo.GetUser(ad.UserId);

            string userPopover   = $"<a data-toggle='popover'  data-container='body'  data-placement='top' data-html='true' data-content='<b>Email</b>: {owner.Email}<br><b>Phone</b>: {owner.Phone}'>{owner.Name}</a>";
            string reportPopover = $"<a data-toggle='popover'  data-container='body'  data-placement='top' data-html='true' data-content='<b>Type</b>: {report.Type}<br><b>Comment</b>: {report.Comment}'>reported</a>";
            string message       = $"<a href='/Home/Ad/?id={ad.Id}&category={ad.Category}'>{ad.Title}</a> (owner: {userPopover}) was {reportPopover}! <span class='notification-date'>[{DateTime.Now}]<span>";

            repo.NotifyUser(message, NotificationType.Report, (repo.GetAdmin()).Id);
        }
Ejemplo n.º 2
0
        public override void Handle(Report report, RepoFacade repo)
        {
            if (report.Type == ReportTypes.Scam)
            {
                repo.FreezeAd(report.AdCategory, report.AdId);

                Ad ad = repo.GetAd(report.AdCategory, report.AdId);
                repo.BanUser(ad.UserId);

                User admin = repo.GetAdmin();

                string adminPopover  = $"<a data-toggle='popover' data-container='body' data-placement='top' data-html='true' data-content='Name: {admin.Name}<br>Email: {admin.Email}'>Admin</a>";
                string reportPopover = $"<a data-toggle='popover' data-container='body' data-placement='top' data-html='true' data-content='Type: {report.Type}<br>Comment: {report.Comment}'>reported</a>";
                string message       = $"Your ad <a href='/Home/Ad/?id={ad.Id}&category={ad.Category}'>{ad.Title}</a> was {reportPopover} and now is freezed and you are banned, contact {adminPopover} to solve this problem! <span class='notification-date'>[{DateTime.Now}]</span>";

                repo.NotifyUser(message, NotificationType.Report, ad.UserId);
            }
            Successor.Handle(report, repo);
        }
Ejemplo n.º 3
0
        public async void Buy(int adId, string category)
        {
            User sender = repo.GetUser(User.Identity.Name);
            Ad   ad     = repo.GetAd(category, adId);

            if (ad == null)
            {
                return;
            }

            string userPopover = $"<a data-toggle='popover'  data-container='body'  data-placement='top' data-html='true' data-content='<b>Email</b>: {sender.Email}<br><b>Phone</b>: {sender.Phone}'>{sender.Name}</a>";
            string adLink      = $"<a href='/Home/Ad/?id={ad.Id}&category={ad.Category}'>{ad.Title}</a>";

            string saleText    = $"{userPopover} bought your '{adLink}' <span class='notification-date'>[{DateTime.Now}]</span>";
            string orderedText = $"You ordered '{adLink}' <span class='notification-date'>[{DateTime.Now}]</span>";

            repo.NotifyUser(saleText, NotificationType.Purchase, ad.UserId);
            repo.NotifyUser(orderedText, NotificationType.Sale, sender.Id);

            await Notify(ad.UserId, "New purchase", saleText);
            await Notify(sender.Email, "New order", orderedText);
        }