예제 #1
0
        public void ShouldCreateNewCategory()
        {
            var newShop     = _shopService.Add(EpicShopFixture.NewShop());
            var newCategory = EpicShopFixture.NewCategory(newShop.Id);

            _categoryService.Add(newCategory);
            Assert.True(newShop.Id > 0);
        }
예제 #2
0
        public HttpResponseMessage Add(Shop shop)
        {
            try
            {
                if (shop.ShopName.StartsWith("!,@,#,$,%,^,&,*,(,)._.+,=,-,],[,',;,/,.,>,<,?,|,`.~"))
                {
                    throw new HttpResponseException(HttpStatusCode.NotModified);
                }
                else if (shop.ID < 0)
                {
                    throw new HttpResponseException(HttpStatusCode.NotModified);
                }
                else
                {
                    var newShop = new Shop()
                    {
                        ShopName     = shop.ShopName,
                        Category     = shop.Category,
                        TotalProduct = shop.TotalProduct
                    };
                    shopService.Add(newShop);
                    uow.Complete();
                    var message = Request.CreateResponse(HttpStatusCode.Created, shop);
                    message.Headers.Location = new Uri(Request.RequestUri +
                                                       shop.ID.ToString());

                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
예제 #3
0
        public HttpResponseMessage Add(ShopAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            ItemResponse <int> response = new ItemResponse <int>
            {
                Item = _service.Add(model)
            };

            return(Request.CreateResponse(HttpStatusCode.Created, response));
        }
예제 #4
0
        public void ShouldCreateNewShop()
        {
            var newShop = _shopService.Add(EpicShopFixture.NewShop());

            Assert.True(newShop.Id > 0);
        }