Exemplo n.º 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);
            }
        }
Exemplo n.º 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());
        }