Ejemplo n.º 1
0
        public bool Edit(DevEditModel model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Developers
                    .Single(e => e.DevId == model.DevId);     // && e.OwnerId == _userId

                entity.Name             = model.Name;
                entity.HireDate         = model.HireDate;
                entity.ProficiencyLevel = model.ProficiencyLevel;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        // endpoint
        public IHttpActionResult Put(DevEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = LocalDevService();

            if (!service.Edit(model))
            {
                return(InternalServerError());
            }

            return(Ok(model));
        }