Ejemplo n.º 1
0
        public bool Delete(DashboardNotificationExt model, ref string Msg, Controller ctrl)
        {
            bool status = true;

            //TODO: Get Current Object from DB
            var ItemToDelete = db.DashboardNotifications.FirstOrDefault(m => m.DashboardNotificationID == model.DashboardNotificationID);

            try
            {
                if (ItemToDelete != null)
                {
                    var ForAudiLog = Map(ItemToDelete);
                    //TODO: Check if it is not null, then Remove from DB
                    db.DeleteDashboardNotification(ItemToDelete.DashboardNotificationID);

                    //Add To Log
                    AuditLog(ctrl, AuditAction.Delete, null, ForAudiLog);
                }
            }
            catch (Exception ex)
            {
                Msg    = ErrorHandling.HandleException(ex);
                status = false;
            }
            return(status);
        }
Ejemplo n.º 2
0
 public void MapUpdate(ref DashboardNotifications dbmodel, DashboardNotificationExt model)
 {
     dbmodel.DashboardNotificationID = model.DashboardNotificationID;
     dbmodel.Title                = model.Title;
     dbmodel.Summary              = model.Summary;
     dbmodel.Link                 = model.Link;
     dbmodel.LeagueID             = model.LeagueID;
     dbmodel.NotificationDateTime = model.NotificationDateTime;
     dbmodel.IsRecurring          = model.IsRecurring;
     dbmodel.RecurringFrequency   = model.RecurringFrequency;
     dbmodel.DayOfWeek            = model.DayOfWeek;
 }
Ejemplo n.º 3
0
        public bool CreateOrUpdate(DashboardNotificationExt model, ref string Msg, Controller ctrl)
        {
            bool status = true;

            if (model.DashboardNotificationID == 0)
            {
                try
                {
                    //TODO: Map to DB Object
                    var dbmodel = Map(model);
                    //TODO: Save DB Changes and Set the Return Primary Key ID
                    db.DashboardNotifications.Add(dbmodel);
                    db.SaveChanges();

                    //Now Add Same notification for Players Dashboard Notifications
                    AddPlayerDashboardNotifications(dbmodel.DashboardNotificationID, dbmodel.LeagueID);

                    //TOD: Add to Audit Log
                    AuditLog(ctrl, AuditAction.Create, model, null);
                }
                catch (Exception ex)
                {
                    Msg    = ErrorHandling.HandleException(ex);
                    status = false;
                }
            }
            else
            {
                try
                {
                    var dbmodel     = db.DashboardNotifications.FirstOrDefault(p => p.DashboardNotificationID == model.DashboardNotificationID);
                    var ForAuditLog = Map(dbmodel);
                    //TODO: Map to DB Object
                    MapUpdate(ref dbmodel, model);
                    //TODO: Update DB Changes
                    db.SaveChanges();

                    //Now Remove and Then Add Same notification for Players Dashboard Notifications
                    AddPlayerDashboardNotifications(dbmodel.DashboardNotificationID, dbmodel.LeagueID);

                    //TOD: Add to Audit Log
                    AuditLog(ctrl, AuditAction.Update, ForAuditLog, model);
                }
                catch (Exception ex)
                {
                    Msg    = ErrorHandling.HandleException(ex);
                    status = false;
                }
            }

            return(status);
        }
Ejemplo n.º 4
0
        public DashboardNotifications Map(DashboardNotificationExt model)
        {
            DashboardNotifications tblModel = new DashboardNotifications()
            {
                DashboardNotificationID = model.DashboardNotificationID,
                Title                     = model.Title,
                Summary                   = model.Summary,
                Link                      = model.Link,
                LeagueID                  = model.LeagueID,
                NotificationDateTime      = model.NotificationDateTime,
                IsRecurring               = model.IsRecurring,
                RecurringFrequency        = model.RecurringFrequency,
                DayOfWeek                 = model.DayOfWeek,
                IsAchievementNotification = model.IsAchievementNotification
            };

            return(tblModel);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Add the Action to Audit Log
        /// </summary>
        /// <param name="model">The Object for which this Auditlog took place</param>
        /// <param name="Action">"Added New User OR Updated User Details OR Deleted User"</param>

        private void AuditLog(Controller ctrl, AuditAction auditAction, DashboardNotificationExt dbmodel = null, DashboardNotificationExt model = null, string AdditionalMsg = "")
        {
            string AuditLogShortDesc = "", AuditLogLongDesc = "";

            StringBuilder sb = new StringBuilder();

            if (auditAction == AuditAction.Create) //Creating new Record
            {
                AuditLogShortDesc = AuditLogLongDesc = "New Dashboard Notification has been Added " + dbmodel.Title + " Additional Msg: " + AdditionalMsg;
            }
            else if (auditAction == AuditAction.Update)
            {
                AuditLogShortDesc = AuditLogLongDesc = "Dashboard Notification has been Updated " + model.Title + " Additional Msg: " + AdditionalMsg;
            }
            else if (auditAction == AuditAction.Delete)
            {
                AuditLogShortDesc = AuditLogLongDesc = "Dashboard Notification has been Deleted " + model.Title + " Additional Msg: " + AdditionalMsg;
            }

            SecurityUtils.AddAuditLog(AuditLogShortDesc, AuditLogLongDesc, ctrl);
        }
Ejemplo n.º 6
0
        public DashboardNotificationExt Map(DashboardNotifications model)
        {
            DashboardNotificationExt tblModel = new DashboardNotificationExt()
            {
                DashboardNotificationID = model.DashboardNotificationID,
                Title    = model.Title,
                Summary  = model.Summary,
                Link     = model.Link,
                LeagueID = model.LeagueID,

                NotificationDateTime      = model.NotificationDateTime,
                IsRecurring               = model.IsRecurring,
                RecurringFrequency        = model.RecurringFrequency,
                DayOfWeek                 = model.DayOfWeek,
                IsAchievementNotification = model.IsAchievementNotification
            };

            if (tblModel.RecurringFrequency.HasValue)
            {
                switch (tblModel.RecurringFrequency.Value)
                {
                case 1:
                    tblModel.RecurringFrequency_Str = "Daily";
                    break;

                case 2:
                    tblModel.RecurringFrequency_Str = "Weekly";
                    break;

                case 3:
                    tblModel.RecurringFrequency_Str = "Monthly";
                    break;

                default:
                    tblModel.RecurringFrequency_Str = "";
                    break;
                }
            }
            else
            {
                tblModel.RecurringFrequency_Str = "";
            }

            if (tblModel.DayOfWeek.HasValue)
            {
                switch (tblModel.DayOfWeek.Value)
                {
                case 0:
                    tblModel.DayOfWeek_Str = "Sunday";
                    break;

                case 1:
                    tblModel.DayOfWeek_Str = "Monday";
                    break;

                case 2:
                    tblModel.DayOfWeek_Str = "Tuesday";
                    break;

                case 3:
                    tblModel.DayOfWeek_Str = "Wednesday";
                    break;

                case 4:
                    tblModel.DayOfWeek_Str = "Thursday";
                    break;

                case 5:
                    tblModel.DayOfWeek_Str = "Friday";
                    break;

                case 6:
                    tblModel.DayOfWeek_Str = "Saturday";
                    break;

                default:
                    tblModel.DayOfWeek_Str = "";
                    break;
                }
            }
            else
            {
                tblModel.DayOfWeek_Str = "";
            }

            return(tblModel);
        }