Esempio n. 1
0
        public async Task <CategoryData> CreateAsync(CategoryData model)
        {
            var result = await _categoryDataRepository.InsertUpdateAsync(model);

            if (result != null)
            {
                CancelTokens(model);
            }

            return(result);
        }
Esempio n. 2
0
        async Task <int> InsertUpdateInternal(
            int id,
            int parentId,
            int featureId,
            string name,
            string description,
            string alias,
            string iconCss,
            string foreColor,
            string backColor,
            int sortOrder,
            int createdUserId,
            DateTimeOffset?createdDate,
            int modifiedUserId,
            DateTimeOffset?modifiedDate,
            IEnumerable <CategoryData> data)
        {
            var categoryId = 0;

            using (var context = _dbContext)
            {
                categoryId = await context.ExecuteScalarAsync <int>(
                    CommandType.StoredProcedure,
                    "InsertUpdateCategory",
                    new IDbDataParameter[]
                {
                    new DbParam("Id", DbType.Int32, id),
                    new DbParam("ParentId", DbType.Int32, parentId),
                    new DbParam("FeatureId", DbType.Int32, featureId),
                    new DbParam("Name", DbType.String, 255, name.ToEmptyIfNull()),
                    new DbParam("Description", DbType.String, 500, description.ToEmptyIfNull()),
                    new DbParam("Alias", DbType.String, 255, alias.ToEmptyIfNull()),
                    new DbParam("IconCss", DbType.String, 50, iconCss.ToEmptyIfNull()),
                    new DbParam("ForeColor", DbType.String, 50, foreColor.ToEmptyIfNull()),
                    new DbParam("BackColor", DbType.String, 50, backColor.ToEmptyIfNull()),
                    new DbParam("SortOrder", DbType.Int32, sortOrder),
                    new DbParam("CreatedUserId", DbType.Int32, createdUserId),
                    new DbParam("CreatedDate", DbType.DateTimeOffset, createdDate.ToDateIfNull()),
                    new DbParam("ModifiedUserId", DbType.Int32, modifiedUserId),
                    new DbParam("ModifiedDate", DbType.DateTimeOffset, modifiedDate),
                    new DbParam("UniqueId", DbType.Int32, ParameterDirection.Output),
                });
            }

            // Add category data
            if (categoryId > 0)
            {
                if (data != null)
                {
                    foreach (var item in data)
                    {
                        item.CategoryId = categoryId;
                        await _categoryDataRepository.InsertUpdateAsync(item);
                    }
                }
            }

            return(categoryId);
        }