public void ShouldCreateNewCategory() { var newShop = _shopService.Add(EpicShopFixture.NewShop()); var newCategory = EpicShopFixture.NewCategory(newShop.Id); _categoryService.Add(newCategory); Assert.True(newShop.Id > 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)); } }
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)); }
public void ShouldCreateNewShop() { var newShop = _shopService.Add(EpicShopFixture.NewShop()); Assert.True(newShop.Id > 0); }