Example #1
0
        public void ShouldCreatePublisher()
        {
            var model = new CreatePublisherModel
            {
                CompanyName                 = "CompanyName",
                Description                 = "Description",
                EnglishDescription          = "EnglishDescription",
                HomePage                    = "HomePage",
                IsContainEnglishTranslation = true
            };

            _publisherServiceMock.Setup(m => m.Create(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >(), It.IsAny <string>()));

            HttpResponseMessage response = _publishersController.Put(model);

            _publisherServiceMock.Verify(m => m.Create(It.IsAny <string>(), It.IsAny <IDictionary <string, string> >(), It.IsAny <string>()), Times.AtLeastOnce);
            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
        }
Example #2
0
        public HttpResponseMessage Put([FromBody] CreatePublisherModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            IDictionary <string, string> descriptions = new Dictionary <string, string>();

            descriptions.Add("ru", model.Description);

            if (model.IsContainEnglishTranslation)
            {
                descriptions.Add("en", model.EnglishDescription);
            }

            int publisherId = _publisherService.Create(model.CompanyName, descriptions, model.HomePage);

            return(Request.CreateResponse(HttpStatusCode.Created, publisherId));
        }