Пример #1
0
        public bool UpdatePublishingCompany(PublishingCompanyUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.PublishingCompanies.Single(e => e.PublishingCompanyId == model.PublishingCompanyId);

                entity.PublishingCompanyName    = model.PublishingCompanyName;
                entity.PublishingCompanyAddress = model.PublishingCompanyAddress;

                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Put(PublishingCompanyUpdate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_service.UpdatePublishingCompany(model))
            {
                return(InternalServerError());
            }

            return(Ok("Publishing company updated successfully!"));
        }