public IHttpActionResult Post(FaceCreate face) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateFaceService(); if (!service.CreateFace(face)) { return(InternalServerError()); } return(Ok()); }
public bool CreateFace(FaceCreate model) { var entity = new Face() { CharFaceId = _userId, FaceShape = model.FaceShape, EyeShape = model.EyeShape, EyeColor = model.EyeColor, EyebrowShape = model.EyebrowShape, Nose = model.Nose, Mouth = model.Mouth, EarHeight = model.EarHeight, }; using (var ctx = new ApplicationDbContext()) { ctx.Faces.Add(entity); return(ctx.SaveChanges() == 1); } }