Example #1
0
        public async Task <bool> SendReport(Report report, ReportMessage reportMessage, User user)
        {
            if (report == null || user == null || reportMessage == null)
            {
                throw new EntityNotFoundException();
            }

            if (user.Reports.Count == 3)
            {
                return(false);
            }

            user.Reports.Add(report);
            user.ReportMessages.Add(reportMessage);
            report.ReportMessages.Add(reportMessage);

            if (!await database.Complete())
            {
                return(false);
            }

            await notificationSystem.PushNotificationToUsersByRoles(StaticExpressions.NewReportCreated(user.UserName), AdminRoles);

            return(true);
        }