Ejemplo n.º 1
0
        public SharedList Update(SharedList list)
        {
            new SharedListRepository().Update(list);

            _cache.Add <SharedList>(CreateCacheKey(list.Id), list);

            return(list);
        }
Ejemplo n.º 2
0
        public SharedList Create(SharedList list)
        {
            var created = DateTime.UtcNow;

            if (list.Created.Year <= 1)
            {
                list.Created = created;
            }

            list.Id = ListCollectionsApplication.CreateId(list.Name, list.Created);
            new SharedListRepository().Create(list);
            _cache.Add <SharedList>(CreateCacheKey(list.Id), list);

            return(list);
        }
Ejemplo n.º 3
0
        public void Create(SharedList list)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(InsertCommand, connection))
                {
                    command.Parameters.Add("@id", SqlDbType.NVarChar).Value             = list.Id;
                    command.Parameters.Add("@name", SqlDbType.NVarChar).Value           = list.Name;
                    command.Parameters.Add("@created", SqlDbType.DateTime).Value        = list.Created;
                    command.Parameters.Add("@category", SqlDbType.NChar, 100).Value     = list.Category ?? "";
                    command.Parameters.Add("@listcollection", SqlDbType.NVarChar).Value = list.listCollectionId;
                    command.Parameters.Add("@Language", SqlDbType.NVarChar).Value       = list.LanguageId;
                    command.Parameters.Add("@rows", SqlDbType.NVarChar).Value           = JsonConvert.SerializeObject(list.Rows);
                    command.ExecuteNonQuery();
                }

                //foreach (var row in list.Rows)
                //{
                //    using (SqlCommand insertRowommand = new SqlCommand(InsertRowCommand, connection))
                //    {
                //        insertRowommand.Parameters.Add("@id", SqlDbType.NVarChar).Value = row.Id;
                //        insertRowommand.Parameters.Add("@fkListId", SqlDbType.NVarChar).Value = list.Id;

                //        insertRowommand.ExecuteNonQuery();
                //    }

                //    foreach (var column in row.Columns)
                //    {
                //        using (SqlCommand insertColumnCommand = new SqlCommand(InsertColumnCommand, connection))
                //        {
                //            insertColumnCommand.Parameters.Add("@id", SqlDbType.NVarChar).Value = column.Id;
                //            insertColumnCommand.Parameters.Add("@fkRowId", SqlDbType.NVarChar).Value = row.Id;
                //            insertColumnCommand.Parameters.Add("@type", SqlDbType.NVarChar).Value = "string";
                //            insertColumnCommand.Parameters.Add("@value", SqlDbType.NVarChar).Value = column.Content;

                //            insertColumnCommand.ExecuteNonQuery();
                //        }
                //    }
                //}

                connection.Close();
            }
        }
Ejemplo n.º 4
0
 internal void Update(SharedList list)
 {
     using (SqlConnection connection = new SqlConnection(ConnectionString))
     {
         connection.Open();
         using (SqlCommand command = new SqlCommand(UpdateCommand, connection))
         {
             command.Parameters.Add("@id", SqlDbType.NVarChar).Value             = list.Id;
             command.Parameters.Add("@name", SqlDbType.NVarChar).Value           = list.Name;
             command.Parameters.Add("@created", SqlDbType.DateTime).Value        = list.Created;
             command.Parameters.Add("@category", SqlDbType.NChar, 100).Value     = list.Category ?? "";
             command.Parameters.Add("@listcollection", SqlDbType.NVarChar).Value = list.listCollectionId;
             command.Parameters.Add("@Language", SqlDbType.NVarChar).Value       = list.LanguageId;
             command.Parameters.Add("@rows", SqlDbType.NVarChar).Value           = JsonConvert.SerializeObject(list.Rows);
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
 }