public static void Refresh(string _deviceId, List <SynAppsIntentModel> list)
        {
            var dc = new SynAppsIntentDataContext(SqlConnectionString);
            var intentForDelete =
                from n in dc.SynAppsIntents
                where n.SynAppsDeviceId == _deviceId
                where n.IsSynAppsLinked == true
                select n;

            dc.SynAppsIntents.DeleteAllOnSubmit(intentForDelete);

            var intents = new List <SynAppsIntent>();

            foreach (var intent in list)
            {
                intents.Add(new SynAppsIntent
                {
                    SynAppsDeviceId = intent.SynAppsDeviceId,
                    Name            = intent.Name,
                    ReactionBody    = intent.ReactionBody,
                    Entity          = intent.Entity,
                    IsSynAppsLinked = intent.IsSynAppsLinked,
                    CreatedAt       = DateTime.UtcNow
                });
            }
            dc.SynAppsIntents.InsertAllOnSubmit(intents);

            dc.SubmitChanges();
        }
        public void Save()
        {
            var dc = new SynAppsIntentDataContext(SqlConnectionString);

            if (this.Id == 0)
            {
                dc.SynAppsIntents.InsertOnSubmit(new SynAppsIntent
                {
                    SynAppsDeviceId = this.SynAppsDeviceId,
                    Name            = this.Name,
                    ReactionBody    = this.ReactionBody,
                    Entity          = this.Entity,
                    IsSynAppsLinked = this.IsSynAppsLinked,
                    IsDeleted       = this.IsDeleted,
                    CreatedAt       = DateTime.UtcNow
                });
            }
            else
            {
                var reactions =
                    from n in dc.SynAppsIntents
                    where n.Id == this.Id
                    select n;

                foreach (var r in reactions)
                {
                    r.Name            = this.Name;
                    r.ReactionBody    = this.ReactionBody;
                    r.Entity          = this.Entity;
                    r.IsSynAppsLinked = this.IsSynAppsLinked;
                    r.IsDeleted       = this.IsDeleted;
                    r.UpdatedAt       = DateTime.UtcNow;
                }
            }
            dc.SubmitChanges();
        }