Beispiel #1
0
        public bool UpdateTransportations(TransEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Transportations
                    .Single(e => e.TransId == model.TransId);
                entity.TransType = model.TransType;
                entity.DestId    = model.DestId;

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

            var service = CreateTransService();

            if (!service.UpdateTransportations(transportation))
            {
                return(InternalServerError());
            }

            return(Ok());
        }