public IHttpActionResult Put(FaceEdit face) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateFaceService(); if (!service.UpdateFace(face)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateFace(FaceEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Faces .Single(e => e.FaceId == model.FaceId && e.CharFaceId == _userId); entity.FaceShape = model.FaceShape; entity.EyeShape = model.EyeShape; entity.EyeColor = model.EyeColor; entity.EyebrowShape = entity.EyebrowShape; entity.Nose = model.Nose; entity.Mouth = model.Mouth; entity.EarHeight = model.EarHeight; return(ctx.SaveChanges() == 1); } }