Пример #1
0
        public IHttpActionResult Post(FaceCreate face)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateFaceService();

            if (!service.CreateFace(face))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Пример #2
0
        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);
            }
        }