public Task<HttpResponseMessage> AlterarSenha(UsuarioModel model) { HttpResponseMessage response; try { var identity = (ClaimsPrincipal) Thread.CurrentPrincipal; var usuarioNome = identity.Claims.Where(c => c.Type == ClaimTypes.GivenName) .Select(c => c.Value).SingleOrDefault(); var usuario = new Usuario { UsuarioNome = usuarioNome, Senha = model.Senha }; _usuarioService.AlterarSenha(usuario); response = ReturnSuccess(); } catch (Exception ex) { response = ReturnError(ex); } var tsc = new TaskCompletionSource<HttpResponseMessage>(); tsc.SetResult(response); return tsc.Task; }
public Task<HttpResponseMessage> CriarUsuario(UsuarioModel model) { HttpResponseMessage response; try { if (model.GrupoId == null) { throw new Exception(string.Format(Erros.NullParameter, "GrupoId")); } _usuarioService.Registrar(model.UsuarioNome, model.Senha, model.ConfirmarSenha, model.GrupoId.Value); response = ReturnSuccess(); } catch (Exception ex) { response = ReturnError(ex); } var tsc = new TaskCompletionSource<HttpResponseMessage>(); tsc.SetResult(response); return tsc.Task; }
public Task<HttpResponseMessage> EditarUsuario(UsuarioModel model) { HttpResponseMessage response; try { var usuario = Mapper.Map<Usuario>(model); _usuarioService.EditarUsuario(usuario); response = ReturnSuccess(); } catch (Exception ex) { response = ReturnError(ex); } var tsc = new TaskCompletionSource<HttpResponseMessage>(); tsc.SetResult(response); return tsc.Task; }
public JsonResult NovoUsuario(UsuarioModel model) { var response = ServiceRequest.Post<RetornoBase<object>>(model, "api/Usuario/CriarUsuario"); return ReturnResponse(response); }
public JsonResult EditarUsuario(UsuarioModel model) { var response = ServiceRequest.Put<UsuarioModel>(model, "api/Usuario/EditarUsuario"); return ReturnResponse(response); }
public JsonResult AlterarSenha(UsuarioModel model) { var response = ServiceRequest.Put<UsuarioModel>(model, "api/Usuario/AlterarSenha"); return ReturnResponse(response); }