Пример #1
0
        public void ShouldUpdatePublisher()
        {
            var model = new UpdatePublisherModel
            {
                Description        = "Description",
                EnglishDescription = "EnglishDescription",
                HomePage           = "HomePage",
                Id = 1,
                IsContainEnglishTranslation = true
            };

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

            HttpResponseMessage response = _publishersController.Post(model);

            _publisherServiceMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <IDictionary <string, string> >(), It.IsAny <string>()), Times.AtLeastOnce);
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
Пример #2
0
        public HttpResponseMessage Post([FromBody] UpdatePublisherModel 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);
            }

            _publisherService.Update(model.Id, descriptions, model.HomePage);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }