Пример #1
0
        [HttpPut]//Edit
        public IHttpActionResult Put(MuseumEdit museum)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateMuseumService();

            if (!service.UpdateMuseum(museum))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Пример #2
0
        public bool UpdateMuseum(MuseumEdit model)
        {
            using (var db = new ApplicationDbContext())
            {
                var entity =
                    db
                    .Museums
                    .Single(e => e.MuseumId == model.MuseumId);

                entity.MuseumId        = model.MuseumId;
                entity.MuseumName      = model.MuseumName;
                entity.LocationCity    = model.LocationCity;
                entity.LocationCountry = model.LocationCountry;
                entity.CountryCode     = model.CountryCode;

                return(db.SaveChanges() == 1);
            }
        }