Exemplo n.º 1
0
        public static Entities.PublicationEntities.PublicationItem GetPublicationItem(int publicationItemID)
        {
            DAL.Utilities.Helper helper = new DAL.Utilities.Helper(_connectionString);
            Entities.PublicationEntities.PublicationItem publicationItem = new Entities.PublicationEntities.PublicationItem();

            SqlCommand command = new SqlCommand();

            command.CommandTimeout = 10;
            command.CommandType    = CommandType.StoredProcedure;
            command.CommandText    = "GetPublicationItem";

            command.Parameters.Add("@PublicationItemID", System.Data.SqlDbType.Int).Value = publicationItemID;

            DataTable dataTable = helper.GetDataTable(command);

            if (dataTable.Rows.Count == 0)
            {
                publicationItem = null;
            }
            else
            {
                publicationItem = DAL.PublicationDAL.PublicationItemEntityTransformer.ConvertRowToPublicationItem(dataTable.Rows[0]);
            }

            return(publicationItem);
        }
Exemplo n.º 2
0
        public static List <Entities.PublicationEntities.PublicationTask> GetPublicationTasks()
        {
            DAL.Utilities.Helper helper = new DAL.Utilities.Helper(_connectionString);

            string sql = string.Empty;

            sql += "SELECT * FROM PublicationTask;";

            SqlCommand command = new SqlCommand(sql);

            DataTable dataTable = helper.GetDataTable(command);

            return(helper.ToList(dataTable, PublicationDAL.PublicationTaskEntityTransformer.ConvertRowToPublicationTask));
        }
Exemplo n.º 3
0
        public static List <Entities.PublicationEntities.PublicationItem> GetPublicationItems(int publicationTaskID)
        {
            DAL.Utilities.Helper helper = new DAL.Utilities.Helper(_connectionString);

            SqlCommand command = new SqlCommand();

            command.CommandTimeout = 10;
            command.CommandText    = "GetPublicationItems";
            command.CommandType    = CommandType.StoredProcedure;

            command.Parameters.Add("@PublicationTaskID", System.Data.SqlDbType.Int).Value = publicationTaskID;

            DataTable dataTable = helper.GetDataTable(command);

            return(helper.ToList(dataTable, DAL.PublicationDAL.PublicationItemEntityTransformer.ConvertRowToPublicationItem));
        }
Exemplo n.º 4
0
        public static bool DeletePublicationTask(int publicationTaskID)
        {
            DAL.Utilities.Helper helper = new DAL.Utilities.Helper(_connectionString);

            string sql = string.Empty;

            sql += @"DELETE FROM PublicationTask ";
            sql += @"WHERE PublicationTaskID = @PublicationTaskID ";

            SqlCommand command = new SqlCommand(sql);

            command.Parameters.Add("@PublicationTaskID", System.Data.SqlDbType.Int).Value = publicationTaskID;

            bool result = helper.ExecuteCommand(command);

            command.Dispose();

            return(result);
        }
Exemplo n.º 5
0
        public static bool SavePublicationItem(Entities.PublicationEntities.PublicationItem publicationItem)
        {
            bool result = false;

            SqlCommand command = new SqlCommand();

            command.CommandTimeout = 10;
            command.CommandType    = CommandType.StoredProcedure;
            command.CommandText    = "SavePublicationItem";

            command.Parameters.Add("@PublicationItemID", System.Data.SqlDbType.Int).Value = publicationItem.PublicationItemID;
            command.Parameters.Add("@PublicationTaskID", System.Data.SqlDbType.Int).Value = publicationItem.PublicationTaskID;
            command.Parameters.Add("@Name", System.Data.SqlDbType.NVarChar).Value         = publicationItem.Name;
            command.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value            = publicationItem.Status;

            DAL.Utilities.Helper helper = new DAL.Utilities.Helper(_connectionString);
            result = helper.ExecuteCommand(command);

            command.Dispose();

            return(result);
        }
Exemplo n.º 6
0
        public static Entities.PublicationEntities.PublicationItem CreatePublicationItem(Entities.PublicationEntities.PublicationItem publicationItem)
        {
            string sql = string.Empty;

            sql  = @"INSERT INTO PublicationTaskItem (PublicationTaskID, Name, Status) ";
            sql += @"VALUES (@PublicationTaskID, @Name, @Status);";
            sql += @"SELECT CAST(SCOPE_IDENTITY() AS INT)";

            try
            {
                SqlCommand command = new SqlCommand(sql);
                command.CommandText = sql;

                command.Parameters.Add("@PublicationTaskID", System.Data.SqlDbType.Int).Value = publicationItem.PublicationTaskID;
                command.Parameters.Add("@Name", System.Data.SqlDbType.NVarChar).Value         = publicationItem.Name;
                command.Parameters.Add("@Status", System.Data.SqlDbType.Int).Value            = publicationItem.Status;

                DAL.Utilities.Helper helper = new DAL.Utilities.Helper(_connectionString);
                int publicationItemID       = helper.ExecuteCommandScalar(command);

                if (publicationItemID > 0)
                {
                    publicationItem.PublicationItemID = publicationItemID;
                }
                else
                {
                    publicationItem = null;
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                publicationItem = null;
            }

            return(publicationItem);
        }