public IDtoOutObjects Logout(DtoInLogout dtoInLogout) { DtoOutError error = new DtoOutError(); if (TokenTools.Authentication(dtoInLogout.Token, dtoInLogout.DeviceName)) { Token token = TokenTools.getTokenObjectFromString(dtoInLogout.Token); token.IsDeleted = true; tokensRepository.Edit(token); tokensRepository.Save(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <Token, DtoOutToken>(); }); IMapper mapper = config.CreateMapper(); DtoOutToken dtoOutToken = new DtoOutToken(); mapper.Map(token, dtoOutToken); return(dtoOutToken); } else { NotAuthenticatedException ex = new NotAuthenticatedException(); error.Exception = ex; return(error); } }