Пример #1
0
        public async Task <int> SaveAsync(MetaData data, DataAccessActions action)
        {
            int          id         = 0;
            SqlParameter metaDataId = new SqlParameter("@MetaDataId", DbType.Int32);

            metaDataId.Direction = ParameterDirection.Input;

            if (!data.IsNew)
            {
                metaDataId.Value = data.Id;
            }

            if (action == DataAccessActions.Insert)
            {
                metaDataId.Direction = ParameterDirection.Output;
            }

            var arg = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),

                CreateSqlParameter("@ItemId", data.ItemId),

                CreateSqlParameter("@MetaDataTypeId", (short)data.Type),

                CreateSqlParameter("@Key", data.Key),

                CreateSqlParameter("@Value", data.Value),

                CreateSqlParameter("@CreatedOn", data.CreatedOn),

                CreateSqlParameter("@CreatedBy", data.CreatedBy),

                CreateSqlParameter("@PublishedOn", data.PublishedOn),

                CreateSqlParameter("@PublishedBy", data.PublishedBy),

                CreateSqlParameter("@ModifiedOn", data.ModifiedOn),

                CreateSqlParameter("@ModifiedBy", data.ModifiedBy),

                CreateSqlParameter("@SiteId", data.SiteId),

                metaDataId
            };

            await ExecuteNonQueryAsync(Procedures.MetadataCreateUpdateDelete, arg);

            if (action == DataAccessActions.Insert)
            {
                id = Convert.ToInt32(metaDataId.Value);
            }
            else
            {
                id = data.Id;
            }

            return(id);
        }
Пример #2
0
        public async Task <int> SaveAsync(Menu menu, DataAccessActions action)
        {
            int          id         = 0;
            SqlParameter metaDataId = new SqlParameter("@MenuId", DbType.Int32);

            metaDataId.Direction = ParameterDirection.Input;

            if (!menu.IsNew)
            {
                metaDataId.Value = menu.Id;
            }

            if (action == DataAccessActions.Insert)
            {
                metaDataId.Direction = ParameterDirection.Output;
            }

            var arg = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),

                CreateSqlParameter("@Name", menu.Name),

                CreateSqlParameter("@IsActive", menu.IsActive),

                CreateSqlParameter("@SiteId", menu.SiteId),

                CreateSqlParameter("@CreatedOn", menu.CreatedOn),

                CreateSqlParameter("@CreatedBy", menu.CreatedBy),

                CreateSqlParameter("@ModifiedOn", menu.ModifiedOn),

                CreateSqlParameter("@ModifiedBy", menu.ModifiedBy),

                CreateSqlParameter("@PublishedOn", menu.PublishedOn),

                CreateSqlParameter("@PublishedBy", menu.PublishedBy),

                metaDataId
            };

            await ExecuteNonQueryAsync(Procedures.MenuCreateUpdateDelete, arg);

            if (action == DataAccessActions.Insert)
            {
                id = Convert.ToInt32(metaDataId.Value);
            }
            else
            {
                id = menu.Id;
            }

            return(id);
        }
Пример #3
0
        public async Task SaveMapping(int contentId, int pageId, DataAccessActions action)
        {
            var arg = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),

                CreateSqlParameter("@ContentId", contentId),

                CreateSqlParameter("@PageId", pageId)
            };

            await ExecuteNonQueryAsync(Procedures.ContentToPageMap, arg);
        }
Пример #4
0
        public async Task <int> SaveEmailTemplateAsync(MessagingTemplate t, DataAccessActions action)
        {
            int          id        = 0;
            SqlParameter contentId = new SqlParameter("@Id", DbType.Int32);

            contentId.Direction = ParameterDirection.Input;

            if (!t.IsNew)
            {
                contentId.Value = t.Id;
            }

            if (action == DataAccessActions.Insert)
            {
                contentId.Direction = ParameterDirection.Output;
            }
            var arg = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),

                CreateSqlParameter("@Subject", t.Subject),

                CreateSqlParameter("@TemplateTypeId", (int)t.TemplateType),

                CreateSqlParameter("@Target", (int)t.Target),

                CreateSqlParameter("@ContentId", t.ContentId),

                CreateSqlParameter("@Parameters", t.Parameters),

                CreateSqlParameter("@EmailPriorityId", 1),

                CreateSqlParameter("@EmailBodyFormatId", 1),

                contentId
            };

            await ExecuteNonQueryAsync(Procedures.MessagingTemplateCreateUpdateDelete, arg);

            if (action == DataAccessActions.Insert)
            {
                id = Convert.ToInt32(contentId.Value);
            }
            else
            {
                id = t.Id;
            }

            return(id);
        }
Пример #5
0
        public async Task <int> SaveAsync(Page page, DataAccessActions action)
        {
            int          id     = 0;
            SqlParameter pageId = new SqlParameter("@PageId", DbType.Int32);

            pageId.Direction = ParameterDirection.Input;


            if (action == DataAccessActions.Insert)
            {
                pageId.Direction = ParameterDirection.Output;
            }
            else
            {
                pageId.Value = page.Id;
            }

            var parameters = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),
                CreateSqlParameter("@Name", page.Name),
                CreateSqlParameter("@SiteId", page.SiteId),
                CreateSqlParameter("@IsActive", page.IsActive),
                CreateSqlParameter("@Slug", page.Slug),
                CreateSqlParameter("@CreatedOn", page.CreatedOn),
                CreateSqlParameter("@CreatedBy", page.CreatedBy),
                CreateSqlParameter("@ModifiedOn", page.ModifiedOn),
                CreateSqlParameter("@ModifiedBy", page.ModifiedBy),
                CreateSqlParameter("@PublishedOn", page.PublishedOn),
                CreateSqlParameter("@PublishedBy", page.PublishedBy),
                CreateSqlParameter("@PageTypeId", (int)page.PageType),
                CreateSqlParameter("@ParentPageId", page.ParentId.HasValue ? page.ParentId.Value : new Nullable <int>()),
                CreateSqlParameter("@MasterPageId", page.MasterPageId.HasValue ? page.MasterPageId.Value : new Nullable <int>()),
                CreateSqlParameter("@Title", page.Title),
                pageId
            };

            await ExecuteNonQueryAsync(Procedures.PagesCreateUpdateDelete, parameters);

            if (action == DataAccessActions.Insert)
            {
                id = Convert.ToInt32(pageId.Value);
            }
            else
            {
                id = page.Id;
            }
            return(id);
        }
Пример #6
0
        public async Task <int> SaveAsync(Site site, DataAccessActions action)
        {
            int          id     = 0;
            SqlParameter siteId = new SqlParameter("@SiteId", DbType.Int32);

            siteId.Direction = ParameterDirection.Input;


            if (action == DataAccessActions.Insert)
            {
                siteId.Direction = ParameterDirection.Output;
            }
            else
            {
                siteId.Value = site.Id;
            }

            var parameters = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),
                CreateSqlParameter("@TimeZoneOffset", site.TimeZoneOffset),
                CreateSqlParameter("@PageTitleSeparator", site.PageTitleSeparator),
                CreateSqlParameter("@IsActive", site.IsActive),
                CreateSqlParameter("@Name", site.Name),
                CreateSqlParameter("@Host", site.Host),
                CreateSqlParameter("@Language", site.Language.Code),
                CreateSqlParameter("@ParentSiteId", site.ParentSiteId),
                CreateSqlParameter("@ContentType", site.ContentType),
                CreateSqlParameter("@CreatedOn", site.CreatedOn),
                CreateSqlParameter("@CreatedBy", site.CreatedBy),
                CreateSqlParameter("@ModifiedOn", site.ModifiedOn),
                CreateSqlParameter("@ModifiedBy", site.ModifiedBy),

                siteId
            };

            await ExecuteNonQueryAsync(Procedures.SitesCreateUpdate, parameters);

            if (action == DataAccessActions.Insert)
            {
                id = Convert.ToInt32(siteId.Value);
            }
            else
            {
                id = site.Id;
            }
            return(id);
        }
Пример #7
0
        public async Task <int> SaveAsync(Content content, DataAccessActions action)
        {
            int          id        = 0;
            SqlParameter contentId = new SqlParameter("@contentId", DbType.Int32);

            contentId.Direction = ParameterDirection.Input;

            if (!content.IsNew)
            {
                contentId.Value = content.Id;
            }

            if (action == DataAccessActions.Insert)
            {
                contentId.Direction = ParameterDirection.Output;
            }

            var arg = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),

                CreateSqlParameter("@Name", content.Name),

                CreateSqlParameter("@Title", content.Title),

                CreateSqlParameter("@Body", content.Body),

                CreateSqlParameter("@IsActive", content.IsActive),

                CreateSqlParameter("@ContentTypeId", (int)content.Type),

                CreateSqlParameter("@CreatedOn", content.CreatedOn),

                CreateSqlParameter("@CreatedBy", content.CreatedBy),

                CreateSqlParameter("@PublishedOn", content.PublishedOn),

                CreateSqlParameter("@PublishedBy", content.PublishedBy),

                CreateSqlParameter("@SiteId", content.SiteId),

                CreateSqlParameter("@ModifiedOn", content.ModifiedOn),

                CreateSqlParameter("@ModifiedBy", content.ModifiedBy),

                contentId
            };

            await ExecuteNonQueryAsync(Procedures.ContentCreateUpdateDelete, arg);

            if (action == DataAccessActions.Insert)
            {
                id = Convert.ToInt32(contentId.Value);
            }
            else
            {
                id = content.Id;
            }

            return(id);
        }
Пример #8
0
        public async Task <int> SaveItemAsync(MenuItem menuItem, DataAccessActions action)
        {
            int          id         = 0;
            SqlParameter menuItemId = new SqlParameter("@ItemId", DbType.Int32);

            menuItemId.Direction = ParameterDirection.Input;

            if (!menuItem.IsNew)
            {
                menuItemId.Value = menuItem.Id;
            }

            if (action == DataAccessActions.Insert)
            {
                menuItemId.Direction = ParameterDirection.Output;
            }

            var arg = new SqlParameter[]
            {
                CreateSqlParameter("@Action", (int)action),

                CreateSqlParameter("@MenuId", menuItem.MenuId),

                CreateSqlParameter("@Name", menuItem.Text),

                CreateSqlParameter("@Title", menuItem.Alt),

                CreateSqlParameter("@Url", menuItem.Link),

                CreateSqlParameter("@CreatedOn", menuItem.CreatedOn),

                CreateSqlParameter("@CreatedBy", menuItem.CreatedBy),

                CreateSqlParameter("@PublishedOn", menuItem.PublishedOn),

                CreateSqlParameter("@PublishedBy", menuItem.PublishedBy),

                CreateSqlParameter("@ModifiedOn", menuItem.ModifiedOn),

                CreateSqlParameter("@ModifiedBy", menuItem.ModifiedBy),

                CreateSqlParameter("@IsActive", menuItem.IsActive),

                CreateSqlParameter("@ImagePath", menuItem.ImagePath),

                CreateSqlParameter("@ImagePathAct", menuItem.ImagePathAlt),

                CreateSqlParameter("@Order", menuItem.Order),

                menuItemId
            };

            await ExecuteNonQueryAsync(Procedures.MenuItemsCreateUpdateDelete, arg);

            if (action == DataAccessActions.Insert)
            {
                id = Convert.ToInt32(menuItemId.Value);
            }
            else
            {
                id = menuItem.Id;
            }

            return(id);
        }