Exemplo n.º 1
0
        /// <summary>
        /// Method to delete a report
        /// </summary>
        /// <param name="nickname">Nickname of the player</param>
        /// <returns>If the report was deleted</returns>
        public bool DeleteReport(string nickname)
        {
            bool isDeleteReport = false;

            using (HangmanGameContext db = new HangmanGameContext())
            {
                try
                {
                    ReportMisConduct report = new ReportMisConduct();
                    report = db.ReportMisConduct.SingleOrDefault(reportSearch => reportSearch.idReportedPlayer == nickname);
                    if (report != null)
                    {
                        db.ReportMisConduct.Remove(report);
                        db.SaveChanges();
                        isDeleteReport = true;
                    }
                }
                catch (EntityException exception)
                {
                    TelegramBot.SendToTelegram(exception);
                    LogException.Log(this, exception);
                }
            }
            return(isDeleteReport);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to register a report
        /// </summary>
        /// <param name="report">Data report</param>
        /// <returns>If the report was registered correctly</returns>
        public bool RegisterReport(ReportMisConduct report)
        {
            bool isReport = false;

            using (HangmanGameContext db = new HangmanGameContext())
            {
                try
                {
                    db.ReportMisConduct.Add(report);
                    db.SaveChanges();
                    isReport = true;
                }
                catch (DbEntityValidationException exception)
                {
                    TelegramBot.SendToTelegram(exception);
                    LogException.Log(this, exception);
                }
            }
            return(isReport);
        }