예제 #1
0
        public bool Create(DevCreateModel model)
        {
            // Object Initialization Syntax
            var entity = new DevData()
            {
                Name             = model.Name,
                HireDate         = model.HireDate,
                ProficiencyLevel = model.ProficiencyLevel
            };


            using (var ctx = new ApplicationDbContext())
            {
                ctx.Developers.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
예제 #2
0
        // endpoint
        public IHttpActionResult Create(DevCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //Instantiate the specific dev service
            var service = LocalDevService();

            //Call the appropriate method
            //passing in the appropiate model
            if (!service.Create(model))
            {
                return(InternalServerError());
            }

            return(Ok(model));
        }