Esempio n. 1
0
        public DeleteCategoryResponse DeleteCategory(DeleteCategoryRequest request)
        {
            DeleteCategoryResponse res = new DeleteCategoryResponse();
            string strSP = SqlCommandStore.uspDeleteCategory;

            try
            {
                using (SqlCommand cmd = new SqlCommand(strSP))
                {
                    cmd.Parameters.Add("CategoryID", SqlDbType.BigInt).Value = request.CategoryID;

                    cmd.Parameters.Add("@Return", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;

                    DataSet ds = DB.ExecuteSPDataSet(cmd);
                    res.Code = (ReturnCode)Convert.ToInt32(cmd.Parameters["@Return"].Value);

                    if (res.Code != ReturnCode.Success)
                    {
                        DB.RollBackTran();
                        return(res);
                    }
                    return(res);
                }
            }
            catch (Exception ex)
            {
                LogWriter.WriteLogException(ex);
                res.Code = ReturnCode.Fail;
                return(res);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 删除媒体资源
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public DeleteCategoryResponse DeleteCategories(DeleteCategoryRequest input)
        {
            var client = InitVodClient();

            DeleteCategoryResponse response = client.GetAcsResponse(input);


            return(response);
        }
Esempio n. 3
0
        public static DeleteCategoryResponse Unmarshall(UnmarshallerContext context)
        {
            DeleteCategoryResponse deleteCategoryResponse = new DeleteCategoryResponse();

            deleteCategoryResponse.HttpResponse = context.HttpResponse;
            deleteCategoryResponse.RequestId    = context.StringValue("DeleteCategory.RequestId");

            return(deleteCategoryResponse);
        }
        public static DeleteCategoryResponse Unmarshall(UnmarshallerContext context)
        {
            DeleteCategoryResponse deleteCategoryResponse = new DeleteCategoryResponse();

            deleteCategoryResponse.HttpResponse = context.HttpResponse;
            deleteCategoryResponse.RequestId = context.StringValue("DeleteCategory.RequestId");

            return deleteCategoryResponse;
        }
Esempio n. 5
0
        public DeleteCategoryResponse DeleteCategory(DeleteCategoryRequest deletecategoryRequest)
        {
            var category = categoryRepository.FindCategoryById(deletecategoryRequest.Id);

            categoryRepository.Delete(category);
            var deletebrandresponse = new DeleteCategoryResponse {
                Category = messageMapper.MapToCategoryDto(category)
            };

            return(deletebrandresponse);
        }
        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public DeleteCategoryResponse DelCategory(DeleteCategoryRequest request)
        {
            DeleteCategoryResponse response = new DeleteCategoryResponse();

            try
            {
                response = acsClient.GetAcsResponse(request);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Esempio n. 7
0
        public DeleteCategoryResponse DeleteCategory(DeleteCategoryRequest request)
        {
            DeleteCategoryResponse response = new DeleteCategoryResponse();

            try
            {
                categoryRepository.Delete(request.CategoryId);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public DeleteCategoryResponse DeleteCategory(DeleteCategoryRequest request)
        {
            var response = new DeleteCategoryResponse();

            WithErrorHandling(() =>
            {
                var category = _categoryRepository.FindCategoryById(request.Id);
                _categoryRepository.DeleteCategory(category);

                var categoryDto   = category.MapToCategoryDto();
                response.Category = categoryDto;
                response.Messages.Add("Successfully deleted the category");
                response.StatusCode = HttpStatusCode.OK;
            }, response);

            return(response);
        }
Esempio n. 9
0
        public ActionResult Delete(int categoryId)
        {
            DeleteCategoryRequest  request  = new DeleteCategoryRequest();
            DeleteCategoryResponse response = new DeleteCategoryResponse();

            request.CategoryId = categoryId;
            response           = categoryService.DeleteCategory(request);
            if (response.Success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                CategoryListPageViewModel model = new CategoryListPageViewModel();
                model.Success      = false;
                model.ErrorMessage = response.Message;
                return(View("Index", model));
            }
        }
Esempio n. 10
0
        public async Task DeleteCategoryCommandTestAsync(string identityUserId, int categoryId, DeleteCategoryResponse result)
        {
            DeleteCategoryCommand request = new DeleteCategoryCommand
            {
                IdentityUserId = identityUserId,
                CategoryId     = categoryId,
            };
            DeleteCategoryCommandHandler handler = new DeleteCategoryCommandHandler(_deleteFixture.Context);
            var expectedResult = await handler.Handle(request, new CancellationToken());

            Assert.Equal(expectedResult.IsSuccessful, result.IsSuccessful);
            if (expectedResult.IsSuccessful)
            {
                Category category = await _deleteFixture.Context.Categories.FindAsync(expectedResult.Id);

                Assert.Null(category);
            }
            Assert.Equal(expectedResult.Message, result.Message);
        }