예제 #1
0
        public bool CreateLeader(LeaderCreate model)
        {
            Leader leader = new Leader()
            {
                LeaderName = model.LeaderName,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Leaders.Add(leader);
                return(ctx.SaveChanges() == 1);
            }
        }
예제 #2
0
        public IHttpActionResult Post(LeaderCreate leader)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = new LeaderService();

            if (!service.CreateLeader(leader))
            {
                return(InternalServerError());
            }

            return(Ok());
        }