Ejemplo n.º 1
0
        public bool CreateDept(DeptCreate model)
        {
            var entity = new Dept()
            {
                DeptName       = model.DeptName,
                PersonnelCount = model.PersonnelCount
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.DeptDbSet.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult Post(DeptCreate dept)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateDeptService();

            if (!service.CreateDept(dept))
            {
                return(InternalServerError());
            }
            return(Ok());
        }