Example #1
0
        public static void LogSubscriberAction(this Subscriber subscriber, SIMPLDbEnums.SubActionTypeEnum actionType, User user, bool success)
        {
            var subAction = new TempModel.SubAction
                {
                    ActionDateTime = DateTime.Now,
                    ActionTypeId = (int) actionType,
                    ActionDescription = actionType.GetStringValue(),
                    Success = success
                };

            try
            {
                using (var db = DBContextFactory.CreateContext())
                {
                    subAction.EntityId = db.UniqueIds.First(u => u.UniqueIdValue == user.Name).EntityId;
                    db.SubActions.AddObject(subAction);
                    db.SaveChanges();
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("There was a problem logging the action to the database", ex);
            }
        }