示例#1
0
        public async Task <NameGroupAnswer> CreateTypeAsync(uint categoryId, string typeName)
        {
            var answer   = new NameGroupAnswer {
            };
            var category = await _categoryStore
                           .GetAsync(categoryId);

            if (category == null)
            {
                answer.Error = "Category does not exist!";

                return(answer);
            }

            var type = await _typeStore.GetAsync(typeName);

            if (type != null)
            {
                answer.Error = "Type name already exists!";

                return(answer);
            }

            type = await _typeStore.CreateAsync(categoryId, typeName);

            if (type == null)
            {
                answer.Error = "Failed to create a type!";

                return(answer);
            }

            var option = new NameAnswer {
            };

            answer.Options = new List <NameAnswer>();

            option.Id   = type.Id;
            option.Name = type.Name;

            answer.Id    = category.Id;
            answer.Label = category.Name;
            answer.Options.Add(option);

            return(answer);
        }
示例#2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="editRequest"></param>
        /// <returns></returns>
        public async Task <ResponseMessage <bool> > TypeUpdateAsync(CategoryEditRequest editRequest)
        {
            var response = new ResponseMessage <bool>()
            {
                Extension = false
            };
            var category = await _typeStore.GetAsync(editRequest.Id);

            category.CateName  = editRequest.CateName;
            category.IsDeleted = false;
            response.Extension = await _typeStore.PutEntityAsync(editRequest.Id, category);

            return(response);
        }