Example #1
0
        public IHttpActionResult PutLeader(int id, DTO.Leader vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vm.Id)
            {
                return(BadRequest());
            }

            var email = _db.Leaders.AsNoTracking().Single(x => x.Id == vm.Id).Email;
            var model = vm.ToModel();

            _db.Entry(model).State = EntityState.Modified;

            var user = UserManager.FindByEmail(email);

            user.UserName       = vm.Email;
            user.Email          = vm.Email;
            user.LockoutEnabled = false;

            try {
                UserManager.Update(user);
                _db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException) {
                if (!LeaderExists(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
 public static Models.Leader ToModel(this DTO.Leader src)
 {
     return(Mapper.Map <Models.Leader>(src));
 }