コード例 #1
0
        public IHttpActionResult Post(PublishingCompanyCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            return(Ok("Publishing company created successfully!"));
        }
コード例 #2
0
        public bool CreatePublishingCompany(PublishingCompanyCreate model)
        {
            var entity = new PublishingCompany()
            {
                PublishingCompanyName    = model.PublishingCompanyName,
                PublishingCompanyAddress = model.PublishingCompanyAddress
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.PublishingCompanies.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }